Statistics
| Branch: | Revision:

chunker-player / chunker_player / player_core.h @ a0e0d6ff

History | View | Annotate | Download (2.85 KB)

1
#ifndef _CHUNKER_PLAYER_CORE_H
2
#define _CHUNKER_PLAYER_CORE_H
3

    
4
#include <libavcodec/avcodec.h>
5
#include <libavformat/avformat.h>
6
#include <libswscale/swscale.h>
7

    
8
#include <stdio.h>
9
#include <unistd.h>
10
#include <microhttpd.h>
11
#include "external_chunk_transcoding.h"
12
#include "frame.h"
13
#include "player_defines.h"
14
#include <SDL.h>
15
#include <SDL_thread.h>
16
#include <SDL_mutex.h>
17
// #include <SDL_ttf.h>
18
// #include <SDL_image.h>
19
#include <SDL_video.h>
20

    
21
typedef struct threadVal {
22
        int width;
23
        int height;
24
} ThreadVal;
25

    
26
typedef struct PacketQueue {
27
        AVPacketList *first_pkt;
28
        AVPacketList *last_pkt;
29
        int nb_packets;
30
        int size;
31
        SDL_mutex *mutex;
32
        short int queueType;
33
        int last_frame_extracted; //HINT THIS SHOULD BE MORE THAN 4 BYTES
34
        //total frames lost, as seen from the queue, since last queue init
35
        int total_lost_frames;
36
        int loss_history[LOSS_HISTORY_MAX_SIZE];
37
        int loss_history_index;
38
        //how many frames we are loosing at the moment, calculated over a short sliding time window
39
        //i.e. half a second, expressed in lost_frames/sec
40
        double instant_lost_frames;
41
        double density;
42
        //total number of skip events, as seen from the queue, since last queue init
43
        int total_skips;
44
        int last_skips; //the valued before updating it, for computing delta
45
        int skip_history[LOSS_HISTORY_MAX_SIZE];
46
        int skip_history_index;
47
        //how many skips we are observing, calculated over a short sliding time window
48
        //i.e. half a second, expressed in skips/sec
49
        double instant_skips;
50
        int instant_window_size; //averaging window size, self-correcting based on window_seconds
51
        int instant_window_size_target;
52
        int instant_window_seconds; //we want to compute number of events in a 1sec wide window
53
        int last_window_size_update;
54
        char stats_message[255];
55
        int last_stats_display;
56
} PacketQueue;
57

    
58
AVCodecContext  *aCodecCtx;
59
SDL_Thread *video_thread;
60
uint8_t *outbuf_audio;
61
// short int QueueFillingMode=1;
62
short int QueueStopped;
63
ThreadVal VideoCallbackThreadParams;
64

    
65
int AudioQueueOffset;
66
PacketQueue audioq;
67
PacketQueue videoq;
68
AVPacket AudioPkt, VideoPkt;
69
int AVPlaying;
70
int CurrentAudioFreq;
71
int CurrentAudioSamples;
72

    
73
SDL_Rect *InitRect;
74
SDL_AudioSpec AudioSpecification;
75

    
76
struct SwsContext *img_convert_ctx;
77
int GotSigInt;
78

    
79
long long DeltaTime;
80
short int FirstTimeAudio, FirstTime;
81

    
82
int dimAudioQ;
83
float deltaAudioQ;
84
float deltaAudioQError;
85

    
86
int SaveYUV;
87
char YUVFileName[256];
88
int SaveLoss;
89
char LossTracesFilename[256];
90

    
91
int ChunkerPlayerCore_InitCodecs(int width, int height, int sample_rate, short audio_channels);
92
int ChunkerPlayerCore_AudioEnded();
93
void ChunkerPlayerCore_Stop();
94
void ChunkerPlayerCore_Play();
95
int ChunkerPlayerCore_IsRunning();
96
void ChunkerPlayerCore_ResetAVQueues();
97
int ChunkerPlayerCore_PacketQueuePut(PacketQueue *q, AVPacket *pkt);
98
int ChunkerPlayerCore_EnqueueBlocks(const uint8_t *block, const int block_size);
99
void ChunkerPlayerCore_SetupOverlay(int width, int height);
100

    
101
#endif // _CHUNKER_PLAYER_CORE_H