Mercurial > hg > forks > bilotrip-mj12
annotate liboggplayer-src/src/imp.hpp @ 14:083c73ceb716
Get rid of the vorbis related code.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 05 Aug 2013 16:54:46 +0300 |
parents | 105513a2e3c9 |
children | 74b28a572438 |
rev | line source |
---|---|
2 | 1 #include <oggplayer.h> |
14
083c73ceb716
Get rid of the vorbis related code.
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
2 #ifdef VORBIS_SUPPORT |
2 | 3 #include "SDL_audiocvt.hpp" |
14
083c73ceb716
Get rid of the vorbis related code.
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
4 #endif |
2 | 5 #include <fstream> |
6 #include <vector> | |
7 #include <theora/theora.h> | |
8 #include <vorbis/codec.h> | |
9 #include <boost/thread.hpp> | |
10 #include <boost/bind.hpp> | |
11 #include <boost/thread/mutex.hpp> | |
12 #include <boost/thread/locks.hpp> | |
13 #include <boost/thread/condition.hpp> | |
14 #include <boost/circular_buffer.hpp> | |
15 #include <boost/timer.hpp> | |
16 | |
17 struct OggPlayer::Imp { | |
18 | |
19 Imp() : | |
20 cirbuf(0),video_lock(video_mut, boost::defer_lock){ | |
21 failbit = false; | |
22 playing = false; | |
23 need_close = false; | |
24 time_factor = 1; | |
25 refs = 1; | |
26 } | |
27 | |
28 ~Imp() { | |
29 // open() tears down the partial setup on fail | |
30 if (!failbit) | |
31 close(); | |
32 } | |
33 int queue_page(ogg_page * page); | |
34 bool buffer_data(); | |
35 double get_time(); | |
36 void close(); | |
37 bool init_decoders(); | |
38 bool parse_headers(); | |
39 void open(std::string path, AudioFormat audio_format, int channels, | |
40 int rate, VideoFormat video_format); | |
41 bool decode_audio(); | |
42 bool decode_video(); | |
43 bool ready(); | |
44 void play(); | |
45 void play_loop(); | |
46 | |
47 bool failbit; | |
48 std::ifstream file_in; | |
49 | |
50 int theora_p; | |
51 int vorbis_p; | |
52 | |
53 ogg_sync_state o_sync; | |
54 | |
55 vorbis_comment v_comment; | |
56 theora_info t_info; | |
57 theora_comment t_comment; | |
58 vorbis_info v_info; | |
59 | |
60 ogg_page o_page; | |
61 ogg_packet o_packet; | |
62 | |
63 ogg_stream_state o_tsstate; | |
64 ogg_stream_state o_vsstate; | |
65 | |
66 theora_state t_state; | |
67 vorbis_dsp_state v_state; | |
68 vorbis_block v_block; | |
69 | |
70 int pp_level_max; | |
71 int pp_level; | |
72 int pp_inc; | |
73 | |
74 char* audio_buffer; | |
75 boost::circular_buffer<char> cirbuf; | |
76 unsigned int audio_buffer_size; | |
14
083c73ceb716
Get rid of the vorbis related code.
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
77 #ifdef VORBIS_SUPPORT |
2 | 78 SDL_AudioCVT cvt; |
14
083c73ceb716
Get rid of the vorbis related code.
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
79 #endif |
2 | 80 |
81 bool playing; | |
82 | |
83 boost::thread play_thread; | |
84 boost::mutex audio_mut; | |
85 boost::mutex video_mut; | |
86 boost::condition_variable audio_ready_cond; | |
87 boost::condition_variable video_ready_cond; | |
88 | |
89 bool videobuf_ready; | |
90 double videobuf_time; | |
91 | |
92 bool audio_cache_ready; | |
93 | |
94 // This lock should only be used from the main thread | |
95 boost::unique_lock<boost::mutex> video_lock; | |
96 // These variables are used to identify the frames (not just count them, not a debug variable) | |
97 // see video_buffer_try_lock and video_read | |
98 int frame; | |
99 int last_frame_read; | |
100 | |
101 int audio_bytes_played; | |
102 struct AudioGranulePos { | |
103 int pos; | |
104 double set_time; | |
105 }; | |
106 std::deque<AudioGranulePos> audio_granule_poses; | |
107 double time_factor; | |
108 | |
109 struct PixelFormat{ | |
110 void set(int r,int g,int b,int bpp){ | |
111 r_offset = r; | |
112 g_offset = g; | |
113 b_offset = b; | |
114 this->bpp =bpp; | |
115 } | |
116 int r_offset; | |
117 int g_offset; | |
118 int b_offset; | |
119 // if bpp=4 we have an alpha channel at offset 4 | |
120 int bpp; | |
121 | |
122 } pixel_format; | |
123 bool need_close; | |
124 boost::timer timer; | |
125 int refs; | |
126 }; |