diff options
author | Juan Linietsky <reduzio@gmail.com> | 2015-10-13 01:17:54 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2015-10-13 01:17:54 -0300 |
commit | 52e756752e1db9e4cf7c5bb7e92d44995ad674c4 (patch) | |
tree | fe9dc54a7efac116c61333c959c44a3afc4e5794 /drivers | |
parent | c858515785e2406bfc07da587ffc3bb353b7504c (diff) | |
download | redot-engine-52e756752e1db9e4cf7c5bb7e92d44995ad674c4.tar.gz |
ability to change audio track in theora video
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/theora/video_stream_theora.cpp | 15 | ||||
-rw-r--r-- | drivers/theora/video_stream_theora.h | 9 |
2 files changed, 21 insertions, 3 deletions
diff --git a/drivers/theora/video_stream_theora.cpp b/drivers/theora/video_stream_theora.cpp index 48529d563b..bea49e34b7 100644 --- a/drivers/theora/video_stream_theora.cpp +++ b/drivers/theora/video_stream_theora.cpp @@ -238,6 +238,8 @@ void VideoStreamPlaybackTheora::set_file(const String& p_file) { /* Ogg file open; parse the headers */ /* Only interested in Vorbis/Theora streams */ int stateflag = 0; + + int audio_track_skip=audio_track; while(!stateflag){ int ret=buffer_data(); if(ret==0)break; @@ -264,8 +266,14 @@ void VideoStreamPlaybackTheora::set_file(const String& p_file) { theora_p=1; }else if(!vorbis_p && vorbis_synthesis_headerin(&vi,&vc,&op)>=0){ /* it is vorbis */ - copymem(&vo,&test,sizeof(test)); - vorbis_p=1; + if (audio_track_skip) { + vorbis_info_clear(&vi); + vorbis_comment_clear(&vc); + audio_track_skip--; + } else { + copymem(&vo,&test,sizeof(test)); + vorbis_p=1; + } }else{ /* whatever it is, we don't care about it */ ogg_stream_clear(&test); @@ -677,7 +685,7 @@ int VideoStreamPlaybackTheora::get_channels() const{ void VideoStreamPlaybackTheora::set_audio_track(int p_idx) { - + audio_track=p_idx; } int VideoStreamPlaybackTheora::get_mix_rate() const{ @@ -701,6 +709,7 @@ VideoStreamPlaybackTheora::VideoStreamPlaybackTheora() { texture = Ref<ImageTexture>( memnew(ImageTexture )); mix_callback=NULL; mix_udata=NULL; + audio_track=0; delay_compensation=0; }; diff --git a/drivers/theora/video_stream_theora.h b/drivers/theora/video_stream_theora.h index 77a9ae8667..95c7fe88f6 100644 --- a/drivers/theora/video_stream_theora.h +++ b/drivers/theora/video_stream_theora.h @@ -65,6 +65,8 @@ class VideoStreamPlaybackTheora : public VideoStreamPlayback { AudioMixCallback mix_callback; void* mix_udata; + int audio_track; + protected: void clear(); @@ -113,15 +115,22 @@ class VideoStreamTheora : public VideoStream { OBJ_TYPE(VideoStreamTheora,VideoStream); String file; + int audio_track; + + public: Ref<VideoStreamPlayback> instance_playback() { Ref<VideoStreamPlaybackTheora> pb = memnew( VideoStreamPlaybackTheora ); + pb->set_audio_track(audio_track); pb->set_file(file); return pb; } void set_file(const String& p_file) { file=p_file; } + void set_audio_track(int p_track) { audio_track=p_track; } + + VideoStreamTheora() { audio_track=0; } }; |