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