Statistics
| Branch: | Revision:

chunker-player / chunker_player / player_core.h @ 2f5ae7bb

History | View | Annotate | Download (3.16 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
        AVPacketList *last_pkt;
63
        int nb_packets;
64
        int size;
65
        SDL_mutex *mutex;
66
        short int queueType;
67
        int last_frame_extracted; //HINT THIS SHOULD BE MORE THAN 4 BYTES
68
        //total frames lost, as seen from the queue, since last queue init
69
        int total_lost_frames;
70
        
71
        SHistory PacketHistory;
72
        
73
        double density;
74
        char stats_message[255];
75
} PacketQueue;
76

    
77
AVCodecContext  *aCodecCtx;
78
SDL_Thread *video_thread;
79
SDL_Thread *stats_thread;
80
uint8_t *outbuf_audio;
81
// short int QueueFillingMode=1;
82
short int QueueStopped;
83
ThreadVal VideoCallbackThreadParams;
84

    
85
int AudioQueueOffset;
86
PacketQueue audioq;
87
PacketQueue videoq;
88
AVPacket AudioPkt, VideoPkt;
89
int AVPlaying;
90
int CurrentAudioFreq;
91
int CurrentAudioSamples;
92

    
93
SDL_Rect *InitRect;
94
SDL_AudioSpec AudioSpecification;
95

    
96
struct SwsContext *img_convert_ctx;
97
int GotSigInt;
98

    
99
long long DeltaTime;
100
short int FirstTimeAudio, FirstTime;
101

    
102
int dimAudioQ;
103
float deltaAudioQ;
104
float deltaAudioQError;
105

    
106
int SaveYUV;
107
char YUVFileName[256];
108
int SaveLoss;
109

    
110
char VideoTraceFilename[1024];
111
char AudioTraceFilename[1024];
112
char QoETraceFileName[1024];
113

    
114
char VideoFrameLossRateLogFilename[256];
115
char VideoFrameSkipRateLogFilename[256];
116

    
117
long int decoded_vframes;
118
long int LastSavedVFrame;
119
unsigned char LastSourceIFrameDistance;
120

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

    
131
#endif // _CHUNKER_PLAYER_CORE_H