29 #pragma clang diagnostic push
30 #pragma clang diagnostic ignored "-Wdocumentation"
31 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
32 #include <libavcodec/avcodec.h>
33 #include <libavformat/avformat.h>
34 #include <libavutil/avutil.h>
35 #include <libswscale/swscale.h>
37 #include <libswresample/swresample.h>
38 #include <libavutil/opt.h>
39 #pragma clang diagnostic pop
41 #include <sys/types.h>
77 virtual bool IsReady() {
return isReady; }
86 template<
class T>
struct LLNode
103 template<
class T>
struct LinkedList
108 void (*destructor)(T*);
111 unsigned int Count() {
return _size; }
128 LLNode<T>* cur = first;
132 if(destructor != NULL)
133 destructor(&cur->data);
134 LLNode<T>* tmp = cur;
147 LLNode<T>* node =
new LLNode<T>(value);
151 node->previous = last;
167 void Unshift(T value)
169 LLNode<T>* node =
new LLNode<T>(value);
173 first->previous = node;
186 void Remove(LLNode<T>* node)
195 node->previous->next = node->next;
196 node->next->previous = node->previous;
201 node->next->previous = NULL;
210 last = node->previous;
211 node->previous->next = NULL;
232 *value = first->data;
233 LLNode<T>* tmp = first;
235 if(tmp->next == NULL)
265 LLNode<T>* tmp = last;
267 if(last->previous == NULL)
274 last = last->previous;
294 *value = first->data;
300 bool PeekLast(T* value)
317 unsigned int channels;
322 static void Delete(AudioFrame* frame)
324 for(
int i = 0; i < frame->channels; i++)
325 free(frame->samples[i]);
326 free(frame->samples);
337 static void Delete(VideoFrame* frame)
343 LinkedList<AudioFrame> audioFrames;
344 LinkedList<VideoFrame> videoFrames;
345 LinkedList<AVPacket> videoPackets;
346 LinkedList<AVPacket> audioPackets;
361 AVFormatContext* formatCtx;
362 AVCodecContext* videoCodecCtx;
363 AVCodecContext* audioCodecCtx;
365 struct SwrContext *swr_ctx;
366 int bytesPerAudioSample;
369 int videoStreamIndex, audioStreamIndex;
370 AVStream* videoStream;
371 AVStream* audioStream;
376 bool seekUnavailable;
379 AVContainer container;
386 double mPlaybackRate;
388 int64_t lastDecodedVideoPts;
389 int64_t lastSentVideoPts;
390 int64_t lastDecodedAudioPts;
391 bool showedTimestampGapWarning;
392 bool showedSeekIgnoredWarning;
394 double lastVideoTimestamp;
395 double lastAudioTimestamp;
398 double audio_diff_cum;
399 double audio_diff_avg_coef;
401 double audio_diff_threshold;
402 int audio_diff_avg_count;
411 unsigned int audio_buf_size;
414 unsigned int audio_buf_index;
421 AVPacket audio_packet;
422 uint8_t *audio_pkt_data;
425 bool isReady =
false;
468 void ClearAudioBuffer();
478 const
double MAX_AUDIO_LEAD = .022;
482 const
double MAX_AUDIO_LATENCY = -.045;
484 const
unsigned int MAX_FRAME_SKIP = 1;
487 double AudioOffset();