1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
use ffi::*;

use pipeline::Pipeline;
use element::Element;
use ::Transfer;
use reference::Reference;

use std::ops::{Deref, DerefMut};

unsafe impl Sync for PlayBin {}
unsafe impl Send for PlayBin {}

pub struct PlayBin{
    playbin: Pipeline
}

impl PlayBin{
    pub fn new(name: &str) -> Option<PlayBin>{
        let pipeline = Element::new("playbin",name);
        match pipeline{
            Some(p) => {
                match unsafe{ Pipeline::new_from_gst_pipeline( p.transfer() as *mut GstPipeline) }{
                    Some(p) => Some(PlayBin{ playbin: p }),
                    None => None
                }
            }
            None => None
        }
    }

    pub fn set_audio_sink(&mut self, audio_sink: &Element){
        self.set("audio-sink", audio_sink);
    }

    /*pub fn frame(&self) -> GBuffer{
        GBuffer::new(playbin.get<GstBuffer*>("frame"))
    }*/

    pub fn set_subtitle_font_desc(&mut self, font: &str){
        self.set("subtitle-font-desc", font);
    }

    pub fn set_video_sink(&mut self, video_sink: &Element){
        self.set("video-sink", video_sink);
    }

    pub fn set_vis_plugin(&mut self, vis_plugin: &Element){
        self.set("vis-plugin", vis_plugin);
    }

    pub fn set_volume(&mut self, volume: f64){
        self.set("volume", volume);
    }

    pub fn set_connection_speed(&mut self, connection_speed: u64){
        self.set("connection-speed",connection_speed);
    }

    pub fn set_av_offset(&mut self, av_offset: i64){
        self.set("av-offset", av_offset);
    }

    pub fn set_buffer_duration(&mut self, buffer_duration: i64){
        self.set("buffer-duration",buffer_duration);
    }

    pub fn set_current_audio(&mut self, current_audio: i32){
        self.set("current-audio",current_audio);
    }

    pub fn set_current_text(&mut self, current_text: i32){
        self.set("current-text", current_text);
    }

    /*pub fn set_flags(&self, flags: GstPlayFlags){
        self.set("flags", flags);
    }*/

    pub fn mute(&mut self){
        self.set("mute", 1 as gboolean);
    }

    pub fn unmute(&mut self){
        self.set("mute", 0 as gboolean);
    }

    pub fn set_ring_buffer_max_size(&mut self, ring_buffer_max_size: u64){
        self.set("ring-buffer-max-size", ring_buffer_max_size);
    }

    pub fn set_source(&mut self, source: &Element){
        self.set("source", source);
    }

    pub fn set_subtitle_encoding(&mut self, encoding: &str){
        self.set("subtitle-encoding", encoding);
    }

    pub fn set_suburi(&mut self, suburi: &str){
        self.set("suburi", suburi);
    }

    pub fn set_text_sink(&mut self, textsink: &Element){
        self.set("text-sink", textsink);
    }

    pub fn set_uri(&mut self, uri: &str){
        self.set("uri", uri);
    }

    pub fn set_force_aspect_ratio(&mut self, force_aspect_ratio: bool){
        self.set("force-aspect-ratio", force_aspect_ratio as gboolean);
    }

    pub fn set_audio_stream_combiner(&mut self, audio_stream_combiner: &Element){
        self.set("audio-stream-combiner", audio_stream_combiner);
    }

    pub fn set_video_stream_combiner(&mut self, video_stream_combiner: &Element){
        self.set("video-stream-combiner", video_stream_combiner);
    }

    pub fn set_flags(&mut self, flags: i32){
        self.set("flags", flags);
    }
}

impl ::Transfer for PlayBin{
    unsafe fn transfer(self) -> *mut GstElement{
        self.playbin.transfer()
    }
}

impl Reference for PlayBin{
    fn reference(&self) -> PlayBin{
        PlayBin{ playbin: self.playbin.reference()}
    }
}

impl AsRef<Pipeline> for PlayBin{
    fn as_ref(&self) -> &Pipeline{
        &self.playbin
    }
}

impl AsMut<Pipeline> for PlayBin{
    fn as_mut(&mut self) -> &mut Pipeline{
        &mut self.playbin
    }
}

impl From<PlayBin> for Pipeline{
    fn from(b: PlayBin) -> Pipeline{
        b.playbin
    }
}

impl Deref for PlayBin{
    type Target = Pipeline;
    fn deref(&self) -> &Pipeline{
        &self.playbin
    }
}

impl DerefMut for PlayBin{
    fn deref_mut(&mut self) -> &mut Pipeline{
        &mut self.playbin
    }
}