1 /* 2 * To change this license header, choose License Headers in Project Properties. 3 * To change this template file, choose Tools | Templates 4 * and open the template in the editor. 5 */ 6 7 /* 8 * File: stream_codec.h 9 * Author: nTesla64a 10 * 11 * Created on September 5, 2017, 5:02 PM 12 */ 13 14 #ifndef TINY_STREAM_H 15 #define TINY_STREAM_H 16 17 #include <stdint.h> 18 #include <pthread.h> 19 20 #include "tiny_codec.h" 21 22 #ifdef __cplusplus 23 extern "C" { 24 #endif 25 26 #define VIDEO_STATE_STOPPED (0) 27 #define VIDEO_STATE_QEUED (1) 28 #define VIDEO_STATE_RUNNING (2) 29 30 31 typedef struct stream_codec_s 32 { 33 struct tiny_codec_s codec; 34 pthread_t thread; 35 pthread_mutex_t timer_mutex; 36 pthread_mutex_t video_buffer_mutex; 37 pthread_mutex_t audio_buffer_mutex; 38 volatile int stop; 39 volatile int update_audio; 40 volatile int state; 41 } stream_codec_t, *stream_codec_p; 42 43 44 void stream_codec_init(stream_codec_p s); 45 void stream_codec_clear(stream_codec_p s); 46 void stream_codec_stop(stream_codec_p s, int wait); 47 int stream_codec_check_end(stream_codec_p s); 48 49 void stream_codec_video_lock(stream_codec_p s); 50 void stream_codec_video_unlock(stream_codec_p s); 51 void stream_codec_audio_lock(stream_codec_p s); 52 void stream_codec_audio_unlock(stream_codec_p s); 53 54 int stream_codec_play(stream_codec_p s); 55 56 #ifdef __cplusplus 57 } 58 #endif 59 60 #endif /* TINY_STREAM_H */ 61 62