1 /*
2  * Copyright 2008-2014 Arsen Chaloyan
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  * $Id: mpf_termination_factory.c 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $
17  */
18 
19 #include "mpf_termination_factory.h"
20 #include "mpf_termination.h"
21 
22 /** Assign media engine to termination factory */
mpf_termination_factory_engine_assign(mpf_termination_factory_t * termination_factory,mpf_engine_t * media_engine)23 MPF_DECLARE(apt_bool_t) mpf_termination_factory_engine_assign(
24 										mpf_termination_factory_t *termination_factory,
25 										mpf_engine_t *media_engine)
26 {
27 	if(termination_factory && termination_factory->assign_engine && media_engine) {
28 		return termination_factory->assign_engine(termination_factory,media_engine);
29 	}
30 	return FALSE;
31 }
32 
33 /** Create MPF termination from termination factory */
mpf_termination_create(mpf_termination_factory_t * termination_factory,void * obj,apr_pool_t * pool)34 MPF_DECLARE(mpf_termination_t*) mpf_termination_create(
35 										mpf_termination_factory_t *termination_factory,
36 										void *obj,
37 										apr_pool_t *pool)
38 {
39 	if(termination_factory && termination_factory->create_termination) {
40 		return termination_factory->create_termination(termination_factory,obj,pool);
41 	}
42 	return NULL;
43 }
44 
45 /** Create raw MPF termination. */
mpf_raw_termination_create(void * obj,mpf_audio_stream_t * audio_stream,mpf_video_stream_t * video_stream,apr_pool_t * pool)46 MPF_DECLARE(mpf_termination_t*) mpf_raw_termination_create(
47 										void *obj,
48 										mpf_audio_stream_t *audio_stream,
49 										mpf_video_stream_t *video_stream,
50 										apr_pool_t *pool)
51 {
52 	return mpf_termination_base_create(NULL,obj,NULL,audio_stream,video_stream,pool);
53 }
54 
mpf_termination_destroy(mpf_termination_t * termination)55 MPF_DECLARE(apt_bool_t) mpf_termination_destroy(mpf_termination_t *termination)
56 {
57 	if(termination->vtable && termination->vtable->destroy) {
58 		termination->vtable->destroy(termination);
59 	}
60 	return TRUE;
61 }
62 
63 /** Get termination name */
mpf_termination_name_get(const mpf_termination_t * termination)64 MPF_DECLARE(const char*) mpf_termination_name_get(const mpf_termination_t *termination)
65 {
66 	return termination->name;
67 }
68 
69 /** Get associated object. */
mpf_termination_object_get(const mpf_termination_t * termination)70 MPF_DECLARE(void*) mpf_termination_object_get(const mpf_termination_t *termination)
71 {
72 	return termination->obj;
73 }
74 
75 /** Get audio stream. */
mpf_termination_audio_stream_get(const mpf_termination_t * termination)76 MPF_DECLARE(mpf_audio_stream_t*) mpf_termination_audio_stream_get(const mpf_termination_t *termination)
77 {
78 	return termination->audio_stream;
79 }
80 
81 /** Get video stream. */
mpf_termination_video_stream_get(const mpf_termination_t * termination)82 MPF_DECLARE(mpf_video_stream_t*) mpf_termination_video_stream_get(const mpf_termination_t *termination)
83 {
84 	return termination->video_stream;
85 }
86