Statistics
| Branch: | Revision:

chunker-player / chunker_player / player_core.h @ 59e008ed

History | View | Annotate | Download (3.13 KB)

1 10c75ef7 GiuseppeTropea
#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 e11386c0 CsabaKiraly
#define QUEUE_HISTORY_SIZE (STATISTICS_WINDOW_SIZE*MAX_FPS)
22
23 10c75ef7 GiuseppeTropea
typedef struct threadVal {
24
        int width;
25
        int height;
26
} ThreadVal;
27
28 e11386c0 CsabaKiraly
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 10c75ef7 GiuseppeTropea
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 dae4a53f GiuseppeTropea
        //total frames lost, as seen from the queue, since last queue init
69 10c75ef7 GiuseppeTropea
        int total_lost_frames;
70 e11386c0 CsabaKiraly
        
71
        SHistory PacketHistory;
72
        
73 10c75ef7 GiuseppeTropea
        double density;
74 aa041505 GiuseppeTropea
        char stats_message[255];
75 10c75ef7 GiuseppeTropea
} PacketQueue;
76
77
AVCodecContext  *aCodecCtx;
78
SDL_Thread *video_thread;
79 e11386c0 CsabaKiraly
SDL_Thread *stats_thread;
80 10c75ef7 GiuseppeTropea
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 e11386c0 CsabaKiraly
int CurrentAudioFreq;
91
int CurrentAudioSamples;
92 10c75ef7 GiuseppeTropea
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 31e4e8ba GiuseppeTropea
int SaveYUV;
107
char YUVFileName[256];
108
int SaveLoss;
109 e11386c0 CsabaKiraly
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 10c75ef7 GiuseppeTropea
121
int ChunkerPlayerCore_InitCodecs(int width, int height, int sample_rate, short audio_channels);
122 31e4e8ba GiuseppeTropea
int ChunkerPlayerCore_AudioEnded();
123 10c75ef7 GiuseppeTropea
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