Statistics
| Branch: | Revision:

chunker-player / chunker_player / player_core.h @ 47943338

History | View | Annotate | Download (3.26 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
#define QUEUE_HISTORY_SIZE (STATISTICS_WINDOW_SIZE*MAX_FPS)
22

    
23
typedef struct threadVal {
24
        int width;
25
        int height;
26
} ThreadVal;
27

    
28
typedef struct SStats
29
{
30
        int Lossrate;
31
        int Skiprate;
32
        int PercLossrate;
33
        int PercSkiprate;
34
        int Bitrate; // Kbits/sec
35
        int LastIFrameDistance; // distance from the last received intra-frame
36
} SStats;
37

    
38
typedef struct SHistoryElement
39
{
40
        long int ID;
41
        struct timeval Time;
42
        short int Type;
43
        int Size; // size in bytes
44
        unsigned char Status; // 0 lost; 1 played; 2 skipped
45
        SStats Statistics;
46
} SHistoryElement;
47

    
48
typedef struct SHistory
49
{
50
        SHistoryElement History[QUEUE_HISTORY_SIZE];
51
        int Index; // the position where the next history element will be inserted in
52
        int LogIndex; // the position of the next element that will be logged to file
53
        int QoEIndex; // the position of the next element that will used to evaluate QoE
54
        long int LostCount;
55
        long int PlayedCount;
56
        long int SkipCount;
57
        SDL_mutex *Mutex;
58
} SHistory;
59

    
60
typedef struct PacketQueue {
61
        AVPacketList *first_pkt;
62
        AVPacket *minpts_pkt;
63
        AVPacketList *last_pkt;
64
        int nb_packets;
65
        int size;
66
        SDL_mutex *mutex;
67
        short int queueType;
68
        int last_frame_extracted; //HINT THIS SHOULD BE MORE THAN 4 BYTES
69
        //total frames lost, as seen from the queue, since last queue init
70
        int total_lost_frames;
71
        long cumulative_bitrate;
72
        long cumulative_samples;
73

    
74
        SHistory PacketHistory;
75
        
76
        double density;
77
        char stats_message[255];
78
} PacketQueue;
79

    
80
AVCodecContext  *aCodecCtx;
81
SDL_Thread *video_thread;
82
SDL_Thread *stats_thread;
83
uint8_t *outbuf_audio;
84
// short int QueueFillingMode=1;
85
short int QueueStopped;
86
ThreadVal VideoCallbackThreadParams;
87

    
88
int AudioQueueOffset;
89
PacketQueue audioq;
90
PacketQueue videoq;
91
AVPacket AudioPkt, VideoPkt;
92
int AVPlaying;
93
int CurrentAudioFreq;
94
int CurrentAudioSamples;
95
uint8_t CurrentAudioSilence;
96

    
97
SDL_Rect *InitRect;
98
SDL_AudioSpec *AudioSpecification;
99

    
100
struct SwsContext *img_convert_ctx;
101
int GotSigInt;
102

    
103
long long DeltaTime;
104
short int FirstTimeAudio, FirstTime;
105

    
106
int dimAudioQ;
107
float deltaAudioQ;
108
float deltaAudioQError;
109

    
110
int SaveYUV;
111
char YUVFileName[256];
112
int SaveLoss;
113

    
114
char VideoTraceFilename[1024];
115
char AudioTraceFilename[1024];
116
char QoETraceFileName[1024];
117

    
118
char VideoFrameLossRateLogFilename[256];
119
char VideoFrameSkipRateLogFilename[256];
120

    
121
long int decoded_vframes;
122
long int LastSavedVFrame;
123
unsigned char LastSourceIFrameDistance;
124

    
125
int ChunkerPlayerCore_InitCodecs(char *v_codec, int width, int height, char *audio_codec, int sample_rate, short int audio_channels);
126
int ChunkerPlayerCore_AudioEnded();
127
void ChunkerPlayerCore_Stop();
128
void ChunkerPlayerCore_Play();
129
int ChunkerPlayerCore_IsRunning();
130
void ChunkerPlayerCore_ResetAVQueues();
131
int ChunkerPlayerCore_PacketQueuePut(PacketQueue *q, AVPacket *pkt);
132
int ChunkerPlayerCore_EnqueueBlocks(const uint8_t *block, const int block_size);
133
void ChunkerPlayerCore_SetupOverlay(int width, int height);
134

    
135
#endif // _CHUNKER_PLAYER_CORE_H