00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef MPF_STREAM_H
00020 #define MPF_STREAM_H
00021
00022
00023
00024
00025
00026
00027 #include "mpf_types.h"
00028 #include "mpf_frame.h"
00029 #include "mpf_stream_descriptor.h"
00030 #include "mpf_codec.h"
00031 #include "apt_text_stream.h"
00032
00033 APT_BEGIN_EXTERN_C
00034
00035
00036 typedef struct mpf_audio_stream_vtable_t mpf_audio_stream_vtable_t;
00037
00038
00039 struct mpf_audio_stream_t {
00040
00041 void *obj;
00042
00043 const mpf_audio_stream_vtable_t *vtable;
00044
00045 mpf_termination_t *termination;
00046
00047
00048 const mpf_stream_capabilities_t *capabilities;
00049
00050
00051 mpf_stream_direction_e direction;
00052
00053 mpf_codec_descriptor_t *rx_descriptor;
00054
00055 mpf_codec_descriptor_t *rx_event_descriptor;
00056
00057 mpf_codec_descriptor_t *tx_descriptor;
00058
00059 mpf_codec_descriptor_t *tx_event_descriptor;
00060 };
00061
00062
00063 struct mpf_video_stream_t {
00064
00065 mpf_termination_t *termination;
00066
00067 mpf_stream_direction_e direction;
00068 };
00069
00070
00071 struct mpf_audio_stream_vtable_t {
00072
00073 apt_bool_t (*destroy)(mpf_audio_stream_t *stream);
00074
00075
00076 apt_bool_t (*open_rx)(mpf_audio_stream_t *stream, mpf_codec_t *codec);
00077
00078 apt_bool_t (*close_rx)(mpf_audio_stream_t *stream);
00079
00080 apt_bool_t (*read_frame)(mpf_audio_stream_t *stream, mpf_frame_t *frame);
00081
00082
00083 apt_bool_t (*open_tx)(mpf_audio_stream_t *stream, mpf_codec_t *codec);
00084
00085 apt_bool_t (*close_tx)(mpf_audio_stream_t *stream);
00086
00087 apt_bool_t (*write_frame)(mpf_audio_stream_t *stream, const mpf_frame_t *frame);
00088
00089
00090 void (*trace)(mpf_audio_stream_t *stream, mpf_stream_direction_e direction, apt_text_stream_t *output);
00091 };
00092
00093
00094 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);
00095
00096
00097 MPF_DECLARE(apt_bool_t) mpf_audio_stream_rx_validate(
00098 mpf_audio_stream_t *stream,
00099 const mpf_codec_descriptor_t *descriptor,
00100 const mpf_codec_descriptor_t *event_descriptor,
00101 apr_pool_t *pool);
00102
00103
00104 MPF_DECLARE(apt_bool_t) mpf_audio_stream_tx_validate(
00105 mpf_audio_stream_t *stream,
00106 const mpf_codec_descriptor_t *descriptor,
00107 const mpf_codec_descriptor_t *event_descriptor,
00108 apr_pool_t *pool);
00109
00110
00111 static APR_INLINE apt_bool_t mpf_audio_stream_destroy(mpf_audio_stream_t *stream)
00112 {
00113 if(stream->vtable->destroy)
00114 return stream->vtable->destroy(stream);
00115 return TRUE;
00116 }
00117
00118
00119 static APR_INLINE apt_bool_t mpf_audio_stream_rx_open(mpf_audio_stream_t *stream, mpf_codec_t *codec)
00120 {
00121 if(stream->vtable->open_rx)
00122 return stream->vtable->open_rx(stream,codec);
00123 return TRUE;
00124 }
00125
00126
00127 static APR_INLINE apt_bool_t mpf_audio_stream_rx_close(mpf_audio_stream_t *stream)
00128 {
00129 if(stream->vtable->close_rx)
00130 return stream->vtable->close_rx(stream);
00131 return TRUE;
00132 }
00133
00134
00135 static APR_INLINE apt_bool_t mpf_audio_stream_frame_read(mpf_audio_stream_t *stream, mpf_frame_t *frame)
00136 {
00137 if(stream->vtable->read_frame)
00138 return stream->vtable->read_frame(stream,frame);
00139 return TRUE;
00140 }
00141
00142
00143 static APR_INLINE apt_bool_t mpf_audio_stream_tx_open(mpf_audio_stream_t *stream, mpf_codec_t *codec)
00144 {
00145 if(stream->vtable->open_tx)
00146 return stream->vtable->open_tx(stream,codec);
00147 return TRUE;
00148 }
00149
00150
00151 static APR_INLINE apt_bool_t mpf_audio_stream_tx_close(mpf_audio_stream_t *stream)
00152 {
00153 if(stream->vtable->close_tx)
00154 return stream->vtable->close_tx(stream);
00155 return TRUE;
00156 }
00157
00158
00159 static APR_INLINE apt_bool_t mpf_audio_stream_frame_write(mpf_audio_stream_t *stream, const mpf_frame_t *frame)
00160 {
00161 if(stream->vtable->write_frame)
00162 return stream->vtable->write_frame(stream,frame);
00163 return TRUE;
00164 }
00165
00166
00167 MPF_DECLARE(void) mpf_audio_stream_trace(mpf_audio_stream_t *stream, mpf_stream_direction_e direction, apt_text_stream_t *output);
00168
00169 APT_END_EXTERN_C
00170
00171 #endif