diff options
Diffstat (limited to 'docs/av_api.md')
-rw-r--r-- | docs/av_api.md | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/docs/av_api.md b/docs/av_api.md index 63e6801f..6cd7f79a 100644 --- a/docs/av_api.md +++ b/docs/av_api.md | |||
@@ -110,12 +110,15 @@ Return value: | |||
110 | rtp_session_t* - pointer to a newly created rtp session handler. | 110 | rtp_session_t* - pointer to a newly created rtp session handler. |
111 | ``` | 111 | ``` |
112 | 112 | ||
113 | How to handle rtp session: | 113 | ###How to handle rtp session: |
114 | Take a look at | 114 | Take a look at |
115 | ``` | ||
115 | void* phone_handle_media_transport_poll ( void* _hmtc_args_p ) in phone.c | 116 | void* phone_handle_media_transport_poll ( void* _hmtc_args_p ) in phone.c |
117 | ``` | ||
116 | on example. Basically what you do is just receive a message via: | 118 | on example. Basically what you do is just receive a message via: |
117 | 119 | ``` | |
118 | struct rtp_msg_s* rtp_recv_msg ( rtp_session_t* _session ); | 120 | struct rtp_msg_s* rtp_recv_msg ( rtp_session_t* _session ); |
121 | ``` | ||
119 | 122 | ||
120 | and then you use payload within the rtp_msg_s struct. Don't forget to deallocate it with: | 123 | and then you use payload within the rtp_msg_s struct. Don't forget to deallocate it with: |
121 | void rtp_free_msg ( rtp_session_t* _session, struct rtp_msg_s* _msg ); | 124 | void rtp_free_msg ( rtp_session_t* _session, struct rtp_msg_s* _msg ); |
@@ -124,17 +127,20 @@ Receiving should be thread safe so don't worry about that. | |||
124 | When you capture and encode a payload you want to send it ( obviously ). | 127 | When you capture and encode a payload you want to send it ( obviously ). |
125 | 128 | ||
126 | first create a new message with: | 129 | first create a new message with: |
130 | ``` | ||
127 | struct rtp_msg_s* rtp_msg_new ( rtp_session_t* _session, const uint8_t* _data, uint32_t _length ); | 131 | struct rtp_msg_s* rtp_msg_new ( rtp_session_t* _session, const uint8_t* _data, uint32_t _length ); |
132 | ``` | ||
128 | 133 | ||
129 | and then send it with: | 134 | and then send it with: |
135 | ``` | ||
130 | int rtp_send_msg ( rtp_session_t* _session, struct rtp_msg_s* _msg, void* _core_handler ); | 136 | int rtp_send_msg ( rtp_session_t* _session, struct rtp_msg_s* _msg, void* _core_handler ); |
137 | ``` | ||
131 | 138 | ||
132 | _core_handler is the same network handler as in msi_session_s struct. | 139 | _core_handler is the same network handler as in msi_session_s struct. |
133 | 140 | ||
134 | 141 | ||
135 | |||
136 | ##A/V initialization: | 142 | ##A/V initialization: |
137 | 143 | ``` | |
138 | int init_receive_audio(codec_state *cs); | 144 | int init_receive_audio(codec_state *cs); |
139 | int init_receive_video(codec_state *cs); | 145 | int init_receive_video(codec_state *cs); |
140 | Initialises the A/V decoders. On failure it will print the reason and return 0. On success it will return 1. | 146 | Initialises the A/V decoders. On failure it will print the reason and return 0. On success it will return 1. |
@@ -148,30 +154,36 @@ int video_encoder_refresh(codec_state *cs, int bps); | |||
148 | Reinitialises the video encoder with a new bitrate. ffmpeg does not expose the needed VP8 feature to change the bitrate on the fly, so this serves as a workaround. | 154 | Reinitialises the video encoder with a new bitrate. ffmpeg does not expose the needed VP8 feature to change the bitrate on the fly, so this serves as a workaround. |
149 | In the future, VP8 should be used directly and ffmpeg should be dropped from the dependencies. | 155 | In the future, VP8 should be used directly and ffmpeg should be dropped from the dependencies. |
150 | The variable bps is the required bitrate in bits per second. | 156 | The variable bps is the required bitrate in bits per second. |
151 | 157 | ``` | |
152 | 158 | ||
153 | 159 | ||
154 | ###A/V encoding/decoding: | 160 | ###A/V encoding/decoding: |
155 | 161 | ``` | |
156 | void *encode_video_thread(void *arg); | 162 | void *encode_video_thread(void *arg); |
163 | ``` | ||
157 | Spawns the video encoding thread. The argument should hold a pointer to a codec_state. | 164 | Spawns the video encoding thread. The argument should hold a pointer to a codec_state. |
158 | This function should only be called if video encoding is supported (when init_send_video returns 1). | 165 | This function should only be called if video encoding is supported (when init_send_video returns 1). |
159 | Each video frame gets encoded into a packet, which is sent via RTP. Every 60 frames a new bidirectional interframe is encoded. | 166 | Each video frame gets encoded into a packet, which is sent via RTP. Every 60 frames a new bidirectional interframe is encoded. |
160 | 167 | ``` | |
161 | void *encode_audio_thread(void *arg); | 168 | void *encode_audio_thread(void *arg); |
169 | ``` | ||
162 | Spawns the audio encoding thread. The argument should hold a pointer to a codec_state. | 170 | Spawns the audio encoding thread. The argument should hold a pointer to a codec_state. |
163 | This function should only be called if audio encoding is supported (when init_send_audio returns 1). | 171 | This function should only be called if audio encoding is supported (when init_send_audio returns 1). |
164 | Audio frames are read from the selected audio capture device during intitialisation. This audio capturing can be rerouted to a different device on the fly. | 172 | Audio frames are read from the selected audio capture device during intitialisation. This audio capturing can be rerouted to a different device on the fly. |
165 | Each audio frame is encoded into a packet, and sent via RTP. All audio frames have the same amount of samples, which is defined in AV_codec.h. | 173 | Each audio frame is encoded into a packet, and sent via RTP. All audio frames have the same amount of samples, which is defined in AV_codec.h. |
166 | 174 | ``` | |
167 | int video_decoder_refresh(codec_state *cs, int width, int height); | 175 | int video_decoder_refresh(codec_state *cs, int width, int height); |
176 | ``` | ||
168 | Sets the SDL window dimensions and creates a pixel buffer with the requested size. It also creates a scaling context, which will be used to convert the input image format to YUV420P. | 177 | Sets the SDL window dimensions and creates a pixel buffer with the requested size. It also creates a scaling context, which will be used to convert the input image format to YUV420P. |
169 | 178 | ||
179 | ``` | ||
170 | void *decode_video_thread(void *arg); | 180 | void *decode_video_thread(void *arg); |
181 | ``` | ||
171 | Spawns a video decoding thread. The argument should hold a pointer to a codec_state. The codec_state is assumed to contain a successfully initialised video decoder. | 182 | Spawns a video decoding thread. The argument should hold a pointer to a codec_state. The codec_state is assumed to contain a successfully initialised video decoder. |
172 | This function reads video packets and feeds them to the video decoder. If the video frame's resolution has changed, video_decoder_refresh() is called. Afterwards, the frame is displayed on the SDL window. | 183 | This function reads video packets and feeds them to the video decoder. If the video frame's resolution has changed, video_decoder_refresh() is called. Afterwards, the frame is displayed on the SDL window. |
173 | 184 | ``` | |
174 | void *decode_audio_thread(void *arg); | 185 | void *decode_audio_thread(void *arg); |
186 | ``` | ||
175 | Spawns an audio decoding thread. The argument should hold a pointer to a codec_state. The codec_state is assumed to contain a successfully initialised audio decoder. | 187 | Spawns an audio decoding thread. The argument should hold a pointer to a codec_state. The codec_state is assumed to contain a successfully initialised audio decoder. |
176 | All received audio packets are pushed into a jitter buffer and are reordered. If there is a missing packet, or a packet has arrived too late, it is treated as a lost packet and the audio decoder is informed of the packet loss. The audio decoder will then try to reconstruct the lost packet, based on information from previous packets. | 188 | All received audio packets are pushed into a jitter buffer and are reordered. If there is a missing packet, or a packet has arrived too late, it is treated as a lost packet and the audio decoder is informed of the packet loss. The audio decoder will then try to reconstruct the lost packet, based on information from previous packets. |
177 | Audio is played on the default OpenAL output device. | 189 | Audio is played on the default OpenAL output device. |