UniMRCP  1.7.0
mpf_stream.h
Go to the documentation of this file.
1 /*
2  * Copyright 2008-2015 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 
17 #ifndef MPF_STREAM_H
18 #define MPF_STREAM_H
19 
20 /**
21  * @file mpf_stream.h
22  * @brief MPF Bidirectional Stream
23  */
24 
25 #include "mpf_types.h"
26 #include "mpf_frame.h"
27 #include "mpf_stream_descriptor.h"
28 #include "mpf_codec.h"
29 #include "apt_text_stream.h"
30 
32 
33 /** Declaration of virtual table of audio stream */
35 
36 /** Audio stream */
38  /** External object */
39  void *obj;
40  /** Table of virtual methods */
42  /** Back pointer */
44 
45  /** Stream capabilities */
47 
48  /** Stream direction send/receive (bitmask of mpf_stream_direction_e) */
50  /** Rx codec descriptor */
52  /** Rx event descriptor */
54  /** Tx codec descriptor */
56  /** Tx event descriptor */
58 };
59 
60 /** Video stream */
62  /** Back pointer */
64  /** Stream direction send/receive (bitmask of mpf_stream_direction_e) */
66 };
67 
68 /** Table of audio stream virtual methods */
70  /** Virtual destroy method */
71  apt_bool_t (*destroy)(mpf_audio_stream_t *stream);
72 
73  /** Virtual open receiver method */
74  apt_bool_t (*open_rx)(mpf_audio_stream_t *stream, mpf_codec_t *codec);
75  /** Virtual close receiver method */
76  apt_bool_t (*close_rx)(mpf_audio_stream_t *stream);
77  /** Virtual read frame method */
78  apt_bool_t (*read_frame)(mpf_audio_stream_t *stream, mpf_frame_t *frame);
79 
80  /** Virtual open transmitter method */
81  apt_bool_t (*open_tx)(mpf_audio_stream_t *stream, mpf_codec_t *codec);
82  /** Virtual close transmitter method */
83  apt_bool_t (*close_tx)(mpf_audio_stream_t *stream);
84  /** Virtual write frame method */
85  apt_bool_t (*write_frame)(mpf_audio_stream_t *stream, const mpf_frame_t *frame);
86 
87  /** Virtual trace method */
89 };
90 
91 /** Create audio stream */
93 
94 /** Validate audio stream receiver */
96  mpf_audio_stream_t *stream,
97  const mpf_codec_descriptor_t *descriptor,
98  const mpf_codec_descriptor_t *event_descriptor,
99  apr_pool_t *pool);
100 
101 /** Validate audio stream transmitter */
103  mpf_audio_stream_t *stream,
104  const mpf_codec_descriptor_t *descriptor,
105  const mpf_codec_descriptor_t *event_descriptor,
106  apr_pool_t *pool);
107 
108 /** Destroy audio stream */
109 static APR_INLINE apt_bool_t mpf_audio_stream_destroy(mpf_audio_stream_t *stream)
110 {
111  if(stream->vtable->destroy)
112  return stream->vtable->destroy(stream);
113  return TRUE;
114 }
115 
116 /** Open audio stream receiver */
117 static APR_INLINE apt_bool_t mpf_audio_stream_rx_open(mpf_audio_stream_t *stream, mpf_codec_t *codec)
118 {
119  if(stream->vtable->open_rx)
120  return stream->vtable->open_rx(stream,codec);
121  return TRUE;
122 }
123 
124 /** Close audio stream receiver */
125 static APR_INLINE apt_bool_t mpf_audio_stream_rx_close(mpf_audio_stream_t *stream)
126 {
127  if(stream->vtable->close_rx)
128  return stream->vtable->close_rx(stream);
129  return TRUE;
130 }
131 
132 /** Read frame */
133 static APR_INLINE apt_bool_t mpf_audio_stream_frame_read(mpf_audio_stream_t *stream, mpf_frame_t *frame)
134 {
135  if(stream->vtable->read_frame)
136  return stream->vtable->read_frame(stream,frame);
137  return TRUE;
138 }
139 
140 /** Open audio stream transmitter */
141 static APR_INLINE apt_bool_t mpf_audio_stream_tx_open(mpf_audio_stream_t *stream, mpf_codec_t *codec)
142 {
143  if(stream->vtable->open_tx)
144  return stream->vtable->open_tx(stream,codec);
145  return TRUE;
146 }
147 
148 /** Close audio stream transmitter */
149 static APR_INLINE apt_bool_t mpf_audio_stream_tx_close(mpf_audio_stream_t *stream)
150 {
151  if(stream->vtable->close_tx)
152  return stream->vtable->close_tx(stream);
153  return TRUE;
154 }
155 
156 /** Write frame */
157 static APR_INLINE apt_bool_t mpf_audio_stream_frame_write(mpf_audio_stream_t *stream, const mpf_frame_t *frame)
158 {
159  if(stream->vtable->write_frame)
160  return stream->vtable->write_frame(stream,frame);
161  return TRUE;
162 }
163 
164 /** Trace media path */
166 
168 
169 #endif /* MPF_STREAM_H */
Definition: mpf_stream.h:37
MPF Codec.
Definition: mpf_termination.h:51
mpf_codec_descriptor_t * tx_event_descriptor
Definition: mpf_stream.h:57
Definition: apt_text_stream.h:43
Definition: mpf_stream.h:69
MPF Stream Descriptor.
mpf_termination_t * termination
Definition: mpf_stream.h:43
apt_bool_t mpf_audio_stream_rx_validate(mpf_audio_stream_t *stream, const mpf_codec_descriptor_t *descriptor, const mpf_codec_descriptor_t *event_descriptor, apr_pool_t *pool)
void * obj
Definition: mpf_stream.h:39
const mpf_audio_stream_vtable_t * vtable
Definition: mpf_stream.h:41
#define APT_END_EXTERN_C
Definition: apt.h:38
apt_bool_t(* close_tx)(mpf_audio_stream_t *stream)
Definition: mpf_stream.h:83
mpf_codec_descriptor_t * tx_descriptor
Definition: mpf_stream.h:55
int apt_bool_t
Definition: apt.h:57
Definition: mpf_codec.h:35
Definition: mpf_frame.h:50
apt_bool_t(* read_frame)(mpf_audio_stream_t *stream, mpf_frame_t *frame)
Definition: mpf_stream.h:78
#define MPF_DECLARE(type)
Definition: mpf.h:40
const mpf_stream_capabilities_t * capabilities
Definition: mpf_stream.h:46
Definition: mpf_stream.h:61
Definition: mpf_stream_descriptor.h:43
#define APT_BEGIN_EXTERN_C
Definition: apt.h:36
mpf_stream_direction_e
Definition: mpf_stream_descriptor.h:33
MPF Audio/Video/Named-event Frame.
MPF Types Declarations.
apt_bool_t(* open_rx)(mpf_audio_stream_t *stream, mpf_codec_t *codec)
Definition: mpf_stream.h:74
apt_bool_t(* open_tx)(mpf_audio_stream_t *stream, mpf_codec_t *codec)
Definition: mpf_stream.h:81
mpf_stream_direction_e direction
Definition: mpf_stream.h:49
mpf_termination_t * termination
Definition: mpf_stream.h:63
void mpf_audio_stream_trace(mpf_audio_stream_t *stream, mpf_stream_direction_e direction, apt_text_stream_t *output)
apt_bool_t(* write_frame)(mpf_audio_stream_t *stream, const mpf_frame_t *frame)
Definition: mpf_stream.h:85
mpf_codec_descriptor_t * rx_event_descriptor
Definition: mpf_stream.h:53
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)
mpf_codec_descriptor_t * rx_descriptor
Definition: mpf_stream.h:51
apt_bool_t mpf_audio_stream_tx_validate(mpf_audio_stream_t *stream, const mpf_codec_descriptor_t *descriptor, const mpf_codec_descriptor_t *event_descriptor, apr_pool_t *pool)
apt_bool_t(* destroy)(mpf_audio_stream_t *stream)
Definition: mpf_stream.h:71
apt_bool_t(* close_rx)(mpf_audio_stream_t *stream)
Definition: mpf_stream.h:76
Text Stream Parse/Generate Routine.
Definition: mpf_codec_descriptor.h:63
mpf_stream_direction_e direction
Definition: mpf_stream.h:65