UniMRCP  1.3.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
mpf_stream.h
Go to the documentation of this file.
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_stream.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $
17  */
18 
19 #ifndef MPF_STREAM_H
20 #define MPF_STREAM_H
21 
22 /**
23  * @file mpf_stream.h
24  * @brief MPF Bidirectional Stream
25  */
26 
27 #include "mpf_types.h"
28 #include "mpf_frame.h"
29 #include "mpf_stream_descriptor.h"
30 #include "mpf_codec.h"
31 #include "apt_text_stream.h"
32 
34 
35 /** Declaration of virtual table of audio stream */
37 
38 /** Audio stream */
40  /** External object */
41  void *obj;
42  /** Table of virtual methods */
44  /** Back pointer */
46 
47  /** Stream capabilities */
49 
50  /** Stream direction send/receive (bitmask of mpf_stream_direction_e) */
52  /** Rx codec descriptor */
54  /** Rx event descriptor */
56  /** Tx codec descriptor */
58  /** Tx event descriptor */
60 };
61 
62 /** Video stream */
64  /** Back pointer */
66  /** Stream direction send/receive (bitmask of mpf_stream_direction_e) */
68 };
69 
70 /** Table of audio stream virtual methods */
72  /** Virtual destroy method */
74 
75  /** Virtual open receiver method */
77  /** Virtual close receiver method */
79  /** Virtual read frame method */
81 
82  /** Virtual open transmitter method */
84  /** Virtual close transmitter method */
86  /** Virtual write frame method */
88 
89  /** Virtual trace method */
90  void (*trace)(mpf_audio_stream_t *stream, mpf_stream_direction_e direction, apt_text_stream_t *output);
91 };
92 
93 /** Create audio stream */
94 MPF_DECLARE(mpf_audio_stream_t*) mpf_audio_stream_create(void *obj, const mpf_audio_stream_vtable_t *vtable, const mpf_stream_capabilities_t *capabilities, apr_pool_t *pool);
95 
96 /** Validate audio stream receiver */
98  mpf_audio_stream_t *stream,
99  const mpf_codec_descriptor_t *descriptor,
100  const mpf_codec_descriptor_t *event_descriptor,
101  apr_pool_t *pool);
102 
103 /** Validate audio stream transmitter */
105  mpf_audio_stream_t *stream,
106  const mpf_codec_descriptor_t *descriptor,
107  const mpf_codec_descriptor_t *event_descriptor,
108  apr_pool_t *pool);
109 
110 /** Destroy audio stream */
111 static APR_INLINE apt_bool_t mpf_audio_stream_destroy(mpf_audio_stream_t *stream)
112 {
113  if(stream->vtable->destroy)
114  return stream->vtable->destroy(stream);
115  return TRUE;
116 }
117 
118 /** Open audio stream receiver */
119 static APR_INLINE apt_bool_t mpf_audio_stream_rx_open(mpf_audio_stream_t *stream, mpf_codec_t *codec)
120 {
121  if(stream->vtable->open_rx)
122  return stream->vtable->open_rx(stream,codec);
123  return TRUE;
124 }
125 
126 /** Close audio stream receiver */
127 static APR_INLINE apt_bool_t mpf_audio_stream_rx_close(mpf_audio_stream_t *stream)
128 {
129  if(stream->vtable->close_rx)
130  return stream->vtable->close_rx(stream);
131  return TRUE;
132 }
133 
134 /** Read frame */
135 static APR_INLINE apt_bool_t mpf_audio_stream_frame_read(mpf_audio_stream_t *stream, mpf_frame_t *frame)
136 {
137  if(stream->vtable->read_frame)
138  return stream->vtable->read_frame(stream,frame);
139  return TRUE;
140 }
141 
142 /** Open audio stream transmitter */
143 static APR_INLINE apt_bool_t mpf_audio_stream_tx_open(mpf_audio_stream_t *stream, mpf_codec_t *codec)
144 {
145  if(stream->vtable->open_tx)
146  return stream->vtable->open_tx(stream,codec);
147  return TRUE;
148 }
149 
150 /** Close audio stream transmitter */
151 static APR_INLINE apt_bool_t mpf_audio_stream_tx_close(mpf_audio_stream_t *stream)
152 {
153  if(stream->vtable->close_tx)
154  return stream->vtable->close_tx(stream);
155  return TRUE;
156 }
157 
158 /** Write frame */
159 static APR_INLINE apt_bool_t mpf_audio_stream_frame_write(mpf_audio_stream_t *stream, const mpf_frame_t *frame)
160 {
161  if(stream->vtable->write_frame)
162  return stream->vtable->write_frame(stream,frame);
163  return TRUE;
164 }
165 
166 /** Trace media path */
168 
170 
171 #endif /* MPF_STREAM_H */