Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sink pad ordering #213

Merged
merged 2 commits into from Mar 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion backends/dummy/src/lib.rs
Expand Up @@ -195,7 +195,7 @@ impl WebRtcControllerBackend for DummyWebRtcController {
fn add_ice_candidate(&mut self, _: IceCandidate) {}
fn create_offer(&mut self, _: SendBoxFnOnce<'static, (SessionDescription,)>) {}
fn create_answer(&mut self, _: SendBoxFnOnce<'static, (SessionDescription,)>) {}
fn add_stream(&mut self, _: &mut MediaStream) {}
fn add_stream(&mut self, _: Box<MediaStream>) {}
fn internal_event(&mut self, _: thread::InternalEvent) {}
fn quit(&mut self) {}
}
3 changes: 3 additions & 0 deletions backends/gstreamer/Cargo.toml
Expand Up @@ -23,6 +23,9 @@ version = "0.8"
[dependencies.gstreamer-sys]
version = "0.7"

[dependencies.gstreamer-sdp-sys]
version = "0.7"

[dependencies.gstreamer]
version = "0.13"
features = ["subclassing"]
Expand Down
2 changes: 0 additions & 2 deletions backends/gstreamer/src/media_capture.rs
Expand Up @@ -128,14 +128,12 @@ impl GstMediaDevices {
("audio/x-raw", "Audio/Source")
};
let caps = into_caps(constraints, format)?;
println!("requesting {:?}", caps);
let f = self.monitor.add_filter(filter, &caps);
let devices = self.monitor.get_devices();
if let Some(f) = f {
let _ = self.monitor.remove_filter(f);
}
if let Some(d) = devices.get(0) {
println!("{:?}", d.get_caps());
let element = d.create_element(None)?;
Some(GstMediaTrack { element })
} else {
Expand Down
53 changes: 39 additions & 14 deletions backends/gstreamer/src/media_stream.rs
Expand Up @@ -11,7 +11,6 @@ lazy_static! {
&[
("media", &"audio"),
("encoding-name", &"OPUS"),
("payload", &(97i32)),
],
)
};
Expand All @@ -21,7 +20,6 @@ lazy_static! {
&[
("media", &"video"),
("encoding-name", &"VP8"),
("payload", &(96i32)),
],
)
};
Expand Down Expand Up @@ -50,20 +48,47 @@ impl MediaStream for GStreamerMediaStream {
}

impl GStreamerMediaStream {
pub fn attach_to_webrtc(&mut self, pipeline: &gst::Pipeline, webrtcbin: &gst::Element) {
println!("atttaching a {:?} stream", self.type_);
self.attach_to_pipeline(pipeline);

let caps = match self.type_ {
pub fn caps(&self) -> &gst::Caps {
match self.type_ {
StreamType::Audio => &*RTP_CAPS_OPUS,
StreamType::Video => &*RTP_CAPS_VP8,
};
self.elements
.last()
.as_ref()
.unwrap()
.link_filtered(webrtcbin, caps)
.unwrap();
}
}

pub fn caps_with_payload(&self, payload: i32) -> gst::Caps {
match self.type_ {
StreamType::Audio => {
gst::Caps::new_simple(
"application/x-rtp",
&[
("media", &"audio"),
("encoding-name", &"OPUS"),
("payload", &(payload)),
],
)
}
StreamType::Video => {
gst::Caps::new_simple(
"application/x-rtp",
&[
("media", &"video"),
("encoding-name", &"VP8"),
("payload", &(payload)),
],
)
}
}
}

pub fn insert_capsfilter(&mut self) {
assert!(self.pipeline.is_none());
let capsfilter = gst::ElementFactory::make("capsfilter", None).unwrap();
capsfilter.set_property("caps", self.caps()).unwrap();
self.elements.push(capsfilter);
}

pub fn src_element(&self) -> gst::Element {
self.elements.last().unwrap().clone()
}

pub fn attach_to_pipeline(&mut self, pipeline: &gst::Pipeline) {
Expand Down