mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-25 19:11:06 +00:00
Remove some useless message code
This commit is contained in:
parent
9a364c26c6
commit
cb26c0aaed
2 changed files with 20 additions and 31 deletions
|
@ -19,7 +19,7 @@ fn main() {
|
||||||
};
|
};
|
||||||
|
|
||||||
match msg.view() {
|
match msg.view() {
|
||||||
MessageView::Eos(_) => break,
|
MessageView::Eos => break,
|
||||||
MessageView::Error(err) => {
|
MessageView::Error(err) => {
|
||||||
println!("Error from {}: {} ({:?})", msg.get_src().get_path_string(),
|
println!("Error from {}: {} ({:?})", msg.get_src().get_path_string(),
|
||||||
err.get_error(), err.get_debug());
|
err.get_error(), err.get_debug());
|
||||||
|
|
|
@ -13,7 +13,7 @@ use miniobject::*;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
|
|
||||||
use glib;
|
use glib;
|
||||||
use glib::translate::{from_glib, from_glib_none, from_glib_full, ToGlibPtr};
|
use glib::translate::{from_glib, from_glib_none, from_glib_full};
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct MessageImpl(ffi::GstMessage);
|
pub struct MessageImpl(ffi::GstMessage);
|
||||||
|
@ -24,6 +24,8 @@ unsafe impl MiniObject for MessageImpl {
|
||||||
type GstType = ffi::GstMessage;
|
type GstType = ffi::GstMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO builder pattern for message creation
|
||||||
|
|
||||||
impl MessageImpl {
|
impl MessageImpl {
|
||||||
pub fn get_src(&self) -> Object {
|
pub fn get_src(&self) -> Object {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -37,19 +39,13 @@ impl MessageImpl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_seqnum(&mut self, seqnum: u32) {
|
|
||||||
unsafe {
|
|
||||||
ffi::gst_message_set_seqnum(self.as_mut_ptr(), seqnum)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO get_structure()
|
// TODO get_structure()
|
||||||
|
|
||||||
pub fn view(&self) -> MessageView {
|
pub fn view(&self) -> MessageView {
|
||||||
let type_ = unsafe { (*self.as_ptr()).type_ };
|
let type_ = unsafe { (*self.as_ptr()).type_ };
|
||||||
|
|
||||||
if type_ == ffi::GST_MESSAGE_EOS {
|
if type_ == ffi::GST_MESSAGE_EOS {
|
||||||
MessageView::Eos(Eos(self))
|
MessageView::Eos
|
||||||
} else if type_ == ffi::GST_MESSAGE_ERROR {
|
} else if type_ == ffi::GST_MESSAGE_ERROR {
|
||||||
MessageView::Error(Error(self))
|
MessageView::Error(Error(self))
|
||||||
} else if type_ == ffi::GST_MESSAGE_WARNING {
|
} else if type_ == ffi::GST_MESSAGE_WARNING {
|
||||||
|
@ -63,7 +59,7 @@ impl MessageImpl {
|
||||||
} else if type_ == ffi::GST_MESSAGE_STATE_CHANGED {
|
} else if type_ == ffi::GST_MESSAGE_STATE_CHANGED {
|
||||||
MessageView::StateChanged(StateChanged(self))
|
MessageView::StateChanged(StateChanged(self))
|
||||||
} else if type_ == ffi::GST_MESSAGE_STATE_DIRTY {
|
} else if type_ == ffi::GST_MESSAGE_STATE_DIRTY {
|
||||||
MessageView::StateDirty(StateDirty(self))
|
MessageView::StateDirty
|
||||||
} else if type_ == ffi::GST_MESSAGE_STEP_DONE {
|
} else if type_ == ffi::GST_MESSAGE_STEP_DONE {
|
||||||
MessageView::StepDone(StepDone(self))
|
MessageView::StepDone(StepDone(self))
|
||||||
} else if type_ == ffi::GST_MESSAGE_CLOCK_PROVIDE {
|
} else if type_ == ffi::GST_MESSAGE_CLOCK_PROVIDE {
|
||||||
|
@ -77,19 +73,19 @@ impl MessageImpl {
|
||||||
} else if type_ == ffi::GST_MESSAGE_STREAM_STATUS {
|
} else if type_ == ffi::GST_MESSAGE_STREAM_STATUS {
|
||||||
MessageView::StreamStatus(StreamStatus(self))
|
MessageView::StreamStatus(StreamStatus(self))
|
||||||
} else if type_ == ffi::GST_MESSAGE_APPLICATION {
|
} else if type_ == ffi::GST_MESSAGE_APPLICATION {
|
||||||
MessageView::Application(Application(self))
|
MessageView::Application
|
||||||
} else if type_ == ffi::GST_MESSAGE_ELEMENT {
|
} else if type_ == ffi::GST_MESSAGE_ELEMENT {
|
||||||
MessageView::Element(Element(self))
|
MessageView::Element
|
||||||
} else if type_ == ffi::GST_MESSAGE_SEGMENT_START {
|
} else if type_ == ffi::GST_MESSAGE_SEGMENT_START {
|
||||||
MessageView::SegmentStart(SegmentStart(self))
|
MessageView::SegmentStart(SegmentStart(self))
|
||||||
} else if type_ == ffi::GST_MESSAGE_SEGMENT_DONE {
|
} else if type_ == ffi::GST_MESSAGE_SEGMENT_DONE {
|
||||||
MessageView::SegmentDone(SegmentDone(self))
|
MessageView::SegmentDone(SegmentDone(self))
|
||||||
} else if type_ == ffi::GST_MESSAGE_DURATION_CHANGED {
|
} else if type_ == ffi::GST_MESSAGE_DURATION_CHANGED {
|
||||||
MessageView::DurationChanged(DurationChanged(self))
|
MessageView::DurationChanged
|
||||||
} else if type_ == ffi::GST_MESSAGE_LATENCY {
|
} else if type_ == ffi::GST_MESSAGE_LATENCY {
|
||||||
MessageView::Latency(Latency(self))
|
MessageView::Latency
|
||||||
} else if type_ == ffi::GST_MESSAGE_ASYNC_START {
|
} else if type_ == ffi::GST_MESSAGE_ASYNC_START {
|
||||||
MessageView::AsyncStart(AsyncStart(self))
|
MessageView::AsyncStart
|
||||||
} else if type_ == ffi::GST_MESSAGE_ASYNC_DONE {
|
} else if type_ == ffi::GST_MESSAGE_ASYNC_DONE {
|
||||||
MessageView::AsyncDone(AsyncDone(self))
|
MessageView::AsyncDone(AsyncDone(self))
|
||||||
} else if type_ == ffi::GST_MESSAGE_REQUEST_STATE {
|
} else if type_ == ffi::GST_MESSAGE_REQUEST_STATE {
|
||||||
|
@ -121,33 +117,33 @@ impl MessageImpl {
|
||||||
} else if type_ == ffi::GST_MESSAGE_STREAMS_SELECTED {
|
} else if type_ == ffi::GST_MESSAGE_STREAMS_SELECTED {
|
||||||
MessageView::StreamsSelected(StreamsSelected(self))
|
MessageView::StreamsSelected(StreamsSelected(self))
|
||||||
} else {
|
} else {
|
||||||
unimplemented!()
|
MessageView::Other
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum MessageView<'a> {
|
pub enum MessageView<'a> {
|
||||||
Eos(Eos<'a>),
|
Eos,
|
||||||
Error(Error<'a>),
|
Error(Error<'a>),
|
||||||
Warning(Warning<'a>),
|
Warning(Warning<'a>),
|
||||||
Info(Info<'a>),
|
Info(Info<'a>),
|
||||||
Tag(Tag<'a>),
|
Tag(Tag<'a>),
|
||||||
Buffering(Buffering<'a>),
|
Buffering(Buffering<'a>),
|
||||||
StateChanged(StateChanged<'a>),
|
StateChanged(StateChanged<'a>),
|
||||||
StateDirty(StateDirty<'a>),
|
StateDirty,
|
||||||
StepDone(StepDone<'a>),
|
StepDone(StepDone<'a>),
|
||||||
ClockProvide(ClockProvide<'a>),
|
ClockProvide(ClockProvide<'a>),
|
||||||
ClockLost(ClockLost<'a>),
|
ClockLost(ClockLost<'a>),
|
||||||
NewClock(NewClock<'a>),
|
NewClock(NewClock<'a>),
|
||||||
StructureChange(StructureChange<'a>),
|
StructureChange(StructureChange<'a>),
|
||||||
StreamStatus(StreamStatus<'a>),
|
StreamStatus(StreamStatus<'a>),
|
||||||
Application(Application<'a>),
|
Application,
|
||||||
Element(Element<'a>),
|
Element,
|
||||||
SegmentStart(SegmentStart<'a>),
|
SegmentStart(SegmentStart<'a>),
|
||||||
SegmentDone(SegmentDone<'a>),
|
SegmentDone(SegmentDone<'a>),
|
||||||
DurationChanged(DurationChanged<'a>),
|
DurationChanged,
|
||||||
Latency(Latency<'a>),
|
Latency,
|
||||||
AsyncStart(AsyncStart<'a>),
|
AsyncStart,
|
||||||
AsyncDone(AsyncDone<'a>),
|
AsyncDone(AsyncDone<'a>),
|
||||||
RequestState(RequestState<'a>),
|
RequestState(RequestState<'a>),
|
||||||
StepStart(StepStart<'a>),
|
StepStart(StepStart<'a>),
|
||||||
|
@ -164,11 +160,10 @@ pub enum MessageView<'a> {
|
||||||
StreamCollection(StreamCollection<'a>),
|
StreamCollection(StreamCollection<'a>),
|
||||||
StreamsSelected(StreamsSelected<'a>),
|
StreamsSelected(StreamsSelected<'a>),
|
||||||
Redirect(Redirect<'a>),
|
Redirect(Redirect<'a>),
|
||||||
|
Other,
|
||||||
__NonExhaustive,
|
__NonExhaustive,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Eos<'a>(&'a MessageImpl);
|
|
||||||
|
|
||||||
pub struct Error<'a>(&'a MessageImpl);
|
pub struct Error<'a>(&'a MessageImpl);
|
||||||
impl<'a> Error<'a> {
|
impl<'a> Error<'a> {
|
||||||
pub fn get_error(&self) -> glib::Error {
|
pub fn get_error(&self) -> glib::Error {
|
||||||
|
@ -275,20 +270,14 @@ impl<'a> Buffering<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct StateChanged<'a>(&'a MessageImpl);
|
pub struct StateChanged<'a>(&'a MessageImpl);
|
||||||
pub struct StateDirty<'a>(&'a MessageImpl);
|
|
||||||
pub struct StepDone<'a>(&'a MessageImpl);
|
pub struct StepDone<'a>(&'a MessageImpl);
|
||||||
pub struct ClockProvide<'a>(&'a MessageImpl);
|
pub struct ClockProvide<'a>(&'a MessageImpl);
|
||||||
pub struct ClockLost<'a>(&'a MessageImpl);
|
pub struct ClockLost<'a>(&'a MessageImpl);
|
||||||
pub struct NewClock<'a>(&'a MessageImpl);
|
pub struct NewClock<'a>(&'a MessageImpl);
|
||||||
pub struct StructureChange<'a>(&'a MessageImpl);
|
pub struct StructureChange<'a>(&'a MessageImpl);
|
||||||
pub struct StreamStatus<'a>(&'a MessageImpl);
|
pub struct StreamStatus<'a>(&'a MessageImpl);
|
||||||
pub struct Application<'a>(&'a MessageImpl);
|
|
||||||
pub struct Element<'a>(&'a MessageImpl);
|
|
||||||
pub struct SegmentStart<'a>(&'a MessageImpl);
|
pub struct SegmentStart<'a>(&'a MessageImpl);
|
||||||
pub struct SegmentDone<'a>(&'a MessageImpl);
|
pub struct SegmentDone<'a>(&'a MessageImpl);
|
||||||
pub struct DurationChanged<'a>(&'a MessageImpl);
|
|
||||||
pub struct Latency<'a>(&'a MessageImpl);
|
|
||||||
pub struct AsyncStart<'a>(&'a MessageImpl);
|
|
||||||
pub struct AsyncDone<'a>(&'a MessageImpl);
|
pub struct AsyncDone<'a>(&'a MessageImpl);
|
||||||
pub struct RequestState<'a>(&'a MessageImpl);
|
pub struct RequestState<'a>(&'a MessageImpl);
|
||||||
pub struct StepStart<'a>(&'a MessageImpl);
|
pub struct StepStart<'a>(&'a MessageImpl);
|
||||||
|
|
Loading…
Reference in a new issue