mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-12-20 00:56:30 +00:00
Update to slog 2.0
This commit is contained in:
parent
0cf169aa20
commit
021de8af1f
13 changed files with 118 additions and 76 deletions
|
@ -8,7 +8,7 @@ license = "MIT/Apache-2.0"
|
|||
[dependencies]
|
||||
url = "1.1"
|
||||
gst-plugin = { path="../gst-plugin" }
|
||||
slog = "1.3"
|
||||
slog = "2.0"
|
||||
|
||||
[lib]
|
||||
name = "gstrsfile"
|
||||
|
|
|
@ -19,7 +19,7 @@ use gst_plugin::buffer::*;
|
|||
use gst_plugin::utils::*;
|
||||
use gst_plugin::log::*;
|
||||
|
||||
use slog::*;
|
||||
use slog::Logger;
|
||||
|
||||
#[derive(Debug)]
|
||||
enum StreamingState {
|
||||
|
@ -41,7 +41,7 @@ impl FileSink {
|
|||
"rsfilesink",
|
||||
0,
|
||||
"Rust file sink"),
|
||||
None),
|
||||
o!()),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ use gst_plugin::buffer::*;
|
|||
use gst_plugin::log::*;
|
||||
use gst_plugin::utils::*;
|
||||
|
||||
use slog::*;
|
||||
use slog::Logger;
|
||||
|
||||
#[derive(Debug)]
|
||||
enum StreamingState {
|
||||
|
@ -39,7 +39,7 @@ impl FileSrc {
|
|||
"rsfilesrc",
|
||||
0,
|
||||
"Rust file source"),
|
||||
None),
|
||||
o!()),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ license = "MIT/Apache-2.0"
|
|||
[dependencies]
|
||||
url = "1.1"
|
||||
gst-plugin = { path="../gst-plugin" }
|
||||
slog = "1.3"
|
||||
slog = "2.0"
|
||||
nom = "2.0"
|
||||
flavors = {git = "https://github.com/Geal/flavors.git"}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ use gst_plugin::miniobject::*;
|
|||
use gst_plugin::value::Rational32;
|
||||
use gst_plugin::bytes::*;
|
||||
|
||||
use slog::*;
|
||||
use slog::Logger;
|
||||
|
||||
const AUDIO_STREAM_ID: u32 = 0;
|
||||
const VIDEO_STREAM_ID: u32 = 1;
|
||||
|
@ -177,13 +177,15 @@ impl AudioFormat {
|
|||
flavors::SoundFormat::PCM_ALAW => Some(Caps::new_simple("audio/x-alaw", &[])),
|
||||
flavors::SoundFormat::PCM_ULAW => Some(Caps::new_simple("audio/x-mulaw", &[])),
|
||||
flavors::SoundFormat::AAC => {
|
||||
self.aac_sequence_header.as_ref().map(|header| {
|
||||
Caps::new_simple("audio/mpeg",
|
||||
&[("mpegversion", &4.into()),
|
||||
("framed", &true.into()),
|
||||
("stream-format", &"raw".into()),
|
||||
("codec_data", &header.as_ref().into())])
|
||||
})
|
||||
self.aac_sequence_header
|
||||
.as_ref()
|
||||
.map(|header| {
|
||||
Caps::new_simple("audio/mpeg",
|
||||
&[("mpegversion", &4.into()),
|
||||
("framed", &true.into()),
|
||||
("stream-format", &"raw".into()),
|
||||
("codec_data", &header.as_ref().into())])
|
||||
})
|
||||
}
|
||||
flavors::SoundFormat::SPEEX => {
|
||||
let header = {
|
||||
|
@ -236,17 +238,20 @@ impl AudioFormat {
|
|||
};
|
||||
|
||||
if self.rate != 0 {
|
||||
caps.as_mut().map(|c| {
|
||||
c.get_mut().unwrap().set_simple(&[("rate",
|
||||
&(self.rate as i32).into())])
|
||||
});
|
||||
caps.as_mut()
|
||||
.map(|c| {
|
||||
c.get_mut()
|
||||
.unwrap()
|
||||
.set_simple(&[("rate", &(self.rate as i32).into())])
|
||||
});
|
||||
}
|
||||
if self.channels != 0 {
|
||||
caps.as_mut().map(|c| {
|
||||
c.get_mut().unwrap().set_simple(&[("channels",
|
||||
&(self.channels as i32)
|
||||
.into())])
|
||||
});
|
||||
caps.as_mut()
|
||||
.map(|c| {
|
||||
c.get_mut()
|
||||
.unwrap()
|
||||
.set_simple(&[("channels", &(self.channels as i32).into())])
|
||||
});
|
||||
}
|
||||
|
||||
caps
|
||||
|
@ -273,7 +278,9 @@ impl VideoFormat {
|
|||
format: data_header.codec_id,
|
||||
width: metadata.as_ref().and_then(|m| m.video_width),
|
||||
height: metadata.as_ref().and_then(|m| m.video_height),
|
||||
pixel_aspect_ratio: metadata.as_ref().and_then(|m| m.video_pixel_aspect_ratio),
|
||||
pixel_aspect_ratio: metadata
|
||||
.as_ref()
|
||||
.and_then(|m| m.video_pixel_aspect_ratio),
|
||||
framerate: metadata.as_ref().and_then(|m| m.video_framerate),
|
||||
bitrate: metadata.as_ref().and_then(|m| m.video_bitrate),
|
||||
avc_sequence_header: avc_sequence_header.clone(),
|
||||
|
@ -325,11 +332,13 @@ impl VideoFormat {
|
|||
flavors::CodecId::VP6A => Some(Caps::new_simple("video/x-vp6-flash-alpha", &[])),
|
||||
flavors::CodecId::SCREEN2 => Some(Caps::new_simple("video/x-flash-screen2", &[])),
|
||||
flavors::CodecId::H264 => {
|
||||
self.avc_sequence_header.as_ref().map(|header| {
|
||||
Caps::new_simple("video/x-h264",
|
||||
&[("stream-format", &"avc".into()),
|
||||
("codec_data", &header.as_ref().into())])
|
||||
})
|
||||
self.avc_sequence_header
|
||||
.as_ref()
|
||||
.map(|header| {
|
||||
Caps::new_simple("video/x-h264",
|
||||
&[("stream-format", &"avc".into()),
|
||||
("codec_data", &header.as_ref().into())])
|
||||
})
|
||||
}
|
||||
flavors::CodecId::H263 => Some(Caps::new_simple("video/x-h263", &[])),
|
||||
flavors::CodecId::MPEG4Part2 => {
|
||||
|
@ -344,28 +353,34 @@ impl VideoFormat {
|
|||
};
|
||||
|
||||
if let (Some(width), Some(height)) = (self.width, self.height) {
|
||||
caps.as_mut().map(|c| {
|
||||
c.get_mut().unwrap().set_simple(&[("width",
|
||||
&(width as i32).into()),
|
||||
("height",
|
||||
&(height as i32).into())])
|
||||
});
|
||||
caps.as_mut()
|
||||
.map(|c| {
|
||||
c.get_mut()
|
||||
.unwrap()
|
||||
.set_simple(&[("width", &(width as i32).into()),
|
||||
("height", &(height as i32).into())])
|
||||
});
|
||||
}
|
||||
|
||||
if let Some(par) = self.pixel_aspect_ratio {
|
||||
if *par.numer() != 0 && par.numer() != par.denom() {
|
||||
caps.as_mut().map(|c| {
|
||||
c.get_mut().unwrap().set_simple(&[("pixel-aspect-ratio",
|
||||
&par.into())])
|
||||
});
|
||||
caps.as_mut()
|
||||
.map(|c| {
|
||||
c.get_mut()
|
||||
.unwrap()
|
||||
.set_simple(&[("pixel-aspect-ratio", &par.into())])
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(fps) = self.framerate {
|
||||
if *fps.numer() != 0 {
|
||||
caps.as_mut().map(|c| {
|
||||
c.get_mut().unwrap().set_simple(&[("framerate", &fps.into())])
|
||||
});
|
||||
caps.as_mut()
|
||||
.map(|c| {
|
||||
c.get_mut()
|
||||
.unwrap()
|
||||
.set_simple(&[("framerate", &fps.into())])
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -498,7 +513,7 @@ impl FlvDemux {
|
|||
"rsflvdemux",
|
||||
0,
|
||||
"Rust FLV demuxer"),
|
||||
None),
|
||||
o!()),
|
||||
state: State::Stopped,
|
||||
adapter: Adapter::new(),
|
||||
streaming_state: None,
|
||||
|
@ -518,7 +533,9 @@ impl FlvDemux {
|
|||
|
||||
self.adapter.flush(15).unwrap();
|
||||
|
||||
let buffer = self.adapter.get_buffer(tag_header.data_size as usize).unwrap();
|
||||
let buffer = self.adapter
|
||||
.get_buffer(tag_header.data_size as usize)
|
||||
.unwrap();
|
||||
let map = buffer.map_read().unwrap();
|
||||
let data = map.as_slice();
|
||||
|
||||
|
@ -531,11 +548,13 @@ impl FlvDemux {
|
|||
|
||||
let streaming_state = self.streaming_state.as_mut().unwrap();
|
||||
|
||||
let audio_changed = streaming_state.audio
|
||||
let audio_changed = streaming_state
|
||||
.audio
|
||||
.as_mut()
|
||||
.map(|a| a.update_with_metadata(&metadata))
|
||||
.unwrap_or(false);
|
||||
let video_changed = streaming_state.video
|
||||
let video_changed = streaming_state
|
||||
.video
|
||||
.as_mut()
|
||||
.map(|v| v.update_with_metadata(&metadata))
|
||||
.unwrap_or(false);
|
||||
|
@ -630,7 +649,9 @@ impl FlvDemux {
|
|||
if data_header.sound_format == flavors::SoundFormat::AAC {
|
||||
// Not big enough for the AAC packet header, ship!
|
||||
if tag_header.data_size < 1 + 1 {
|
||||
self.adapter.flush(15 + tag_header.data_size as usize).unwrap();
|
||||
self.adapter
|
||||
.flush(15 + tag_header.data_size as usize)
|
||||
.unwrap();
|
||||
warn!(self.logger,
|
||||
"Too small packet for AAC packet header {}",
|
||||
15 + tag_header.data_size);
|
||||
|
@ -672,7 +693,9 @@ impl FlvDemux {
|
|||
let streaming_state = self.streaming_state.as_ref().unwrap();
|
||||
|
||||
if streaming_state.audio == None {
|
||||
self.adapter.flush((tag_header.data_size + 15) as usize).unwrap();
|
||||
self.adapter
|
||||
.flush((tag_header.data_size + 15) as usize)
|
||||
.unwrap();
|
||||
return Ok(HandleBufferResult::Again);
|
||||
}
|
||||
|
||||
|
@ -689,7 +712,9 @@ impl FlvDemux {
|
|||
}
|
||||
|
||||
if tag_header.data_size < offset {
|
||||
self.adapter.flush((tag_header.data_size - 1) as usize).unwrap();
|
||||
self.adapter
|
||||
.flush((tag_header.data_size - 1) as usize)
|
||||
.unwrap();
|
||||
return Ok(HandleBufferResult::Again);
|
||||
}
|
||||
|
||||
|
@ -697,8 +722,9 @@ impl FlvDemux {
|
|||
self.adapter.flush(offset as usize).unwrap();
|
||||
}
|
||||
|
||||
let mut buffer =
|
||||
self.adapter.get_buffer((tag_header.data_size - 1 - offset) as usize).unwrap();
|
||||
let mut buffer = self.adapter
|
||||
.get_buffer((tag_header.data_size - 1 - offset) as usize)
|
||||
.unwrap();
|
||||
|
||||
{
|
||||
let buffer = buffer.get_mut().unwrap();
|
||||
|
@ -775,7 +801,9 @@ impl FlvDemux {
|
|||
if data_header.codec_id == flavors::CodecId::H264 {
|
||||
// Not big enough for the AVC packet header, ship!
|
||||
if tag_header.data_size < 1 + 4 {
|
||||
self.adapter.flush(15 + tag_header.data_size as usize).unwrap();
|
||||
self.adapter
|
||||
.flush(15 + tag_header.data_size as usize)
|
||||
.unwrap();
|
||||
warn!(self.logger,
|
||||
"Too small packet for AVC packet header {}",
|
||||
15 + tag_header.data_size);
|
||||
|
@ -811,7 +839,9 @@ impl FlvDemux {
|
|||
}
|
||||
flavors::AVCPacketType::EndOfSequence => {
|
||||
// Skip
|
||||
self.adapter.flush(15 + tag_header.data_size as usize).unwrap();
|
||||
self.adapter
|
||||
.flush(15 + tag_header.data_size as usize)
|
||||
.unwrap();
|
||||
return Ok(HandleBufferResult::Again);
|
||||
}
|
||||
}
|
||||
|
@ -822,7 +852,9 @@ impl FlvDemux {
|
|||
let streaming_state = self.streaming_state.as_ref().unwrap();
|
||||
|
||||
if streaming_state.video == None {
|
||||
self.adapter.flush((tag_header.data_size + 15) as usize).unwrap();
|
||||
self.adapter
|
||||
.flush((tag_header.data_size + 15) as usize)
|
||||
.unwrap();
|
||||
return Ok(HandleBufferResult::Again);
|
||||
}
|
||||
|
||||
|
@ -843,7 +875,9 @@ impl FlvDemux {
|
|||
}
|
||||
|
||||
if tag_header.data_size < offset {
|
||||
self.adapter.flush((tag_header.data_size - 1) as usize).unwrap();
|
||||
self.adapter
|
||||
.flush((tag_header.data_size - 1) as usize)
|
||||
.unwrap();
|
||||
return Ok(HandleBufferResult::Again);
|
||||
}
|
||||
|
||||
|
@ -851,8 +885,9 @@ impl FlvDemux {
|
|||
self.adapter.flush(offset as usize).unwrap();
|
||||
}
|
||||
|
||||
let mut buffer =
|
||||
self.adapter.get_buffer((tag_header.data_size - 1 - offset) as usize).unwrap();
|
||||
let mut buffer = self.adapter
|
||||
.get_buffer((tag_header.data_size - 1 - offset) as usize)
|
||||
.unwrap();
|
||||
|
||||
{
|
||||
let buffer = buffer.get_mut().unwrap();
|
||||
|
@ -919,7 +954,11 @@ impl FlvDemux {
|
|||
|
||||
Ok(HandleBufferResult::NeedMoreData)
|
||||
}
|
||||
State::Skipping { audio, video, skip_left: 0 } => {
|
||||
State::Skipping {
|
||||
audio,
|
||||
video,
|
||||
skip_left: 0,
|
||||
} => {
|
||||
self.state = State::Streaming;
|
||||
self.streaming_state = Some(StreamingState::new(audio, video));
|
||||
|
||||
|
@ -997,11 +1036,13 @@ impl FlvDemux {
|
|||
let streaming_state = self.streaming_state.as_mut().unwrap();
|
||||
|
||||
if let Some(pts) = buffer.get_pts() {
|
||||
streaming_state.last_position = streaming_state.last_position
|
||||
streaming_state.last_position = streaming_state
|
||||
.last_position
|
||||
.map(|last| cmp::max(last, pts))
|
||||
.or_else(|| Some(pts));
|
||||
} else if let Some(dts) = buffer.get_dts() {
|
||||
streaming_state.last_position = streaming_state.last_position
|
||||
streaming_state.last_position = streaming_state
|
||||
.last_position
|
||||
.map(|last| cmp::max(last, dts))
|
||||
.or_else(|| Some(dts));
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ license = "MIT/Apache-2.0"
|
|||
url = "1.1"
|
||||
gst-plugin = { path="../gst-plugin" }
|
||||
reqwest = "0.5"
|
||||
slog = "1.3"
|
||||
slog = "2.0"
|
||||
|
||||
[lib]
|
||||
name = "gstrshttp"
|
||||
|
|
|
@ -19,7 +19,7 @@ use gst_plugin::buffer::*;
|
|||
use gst_plugin::utils::*;
|
||||
use gst_plugin::log::*;
|
||||
|
||||
use slog::*;
|
||||
use slog::Logger;
|
||||
|
||||
#[derive(Debug)]
|
||||
enum StreamingState {
|
||||
|
@ -50,7 +50,7 @@ impl HttpSrc {
|
|||
"rshttpsink",
|
||||
0,
|
||||
"Rust http sink"),
|
||||
None),
|
||||
o!()),
|
||||
client: Client::new().unwrap(),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ license = "MIT/Apache-2.0"
|
|||
libc = "0.2"
|
||||
url = "1.1"
|
||||
bitflags = "0.8"
|
||||
slog = { version = "1.3", features = ["max_level_trace"] }
|
||||
slog = { version = "2.0", features = ["max_level_trace"] }
|
||||
lazy_static = "0.2"
|
||||
byteorder = "1.0"
|
||||
num-rational = { version = "0.1", default-features = false, features = [] }
|
||||
|
|
|
@ -11,7 +11,7 @@ use miniobject::*;
|
|||
use log::*;
|
||||
use std::collections::VecDeque;
|
||||
use std::cmp;
|
||||
use slog::*;
|
||||
use slog::Logger;
|
||||
|
||||
lazy_static! {
|
||||
static ref LOGGER: Logger = {
|
||||
|
@ -19,7 +19,7 @@ lazy_static! {
|
|||
"rsadapter",
|
||||
0,
|
||||
"Rust buffer adapter"),
|
||||
None)
|
||||
o!())
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ use std::sync::atomic::{AtomicBool, Ordering};
|
|||
use std::u32;
|
||||
use std::u64;
|
||||
|
||||
use slog::*;
|
||||
use slog::Logger;
|
||||
|
||||
use utils::*;
|
||||
use error::*;
|
||||
|
@ -106,7 +106,7 @@ impl DemuxerWrapper {
|
|||
"rsdemux",
|
||||
0,
|
||||
"Rust demuxer base class"),
|
||||
None),
|
||||
o!()),
|
||||
demuxer: Mutex::new(demuxer),
|
||||
panicked: AtomicBool::new(false),
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
use libc::c_char;
|
||||
use std::ffi::CString;
|
||||
use slog::{Drain, Record, OwnedKeyValueList, Never, Level};
|
||||
use slog::{Drain, Record, OwnedKVList, Never, Level};
|
||||
use std::fmt;
|
||||
use std::ptr;
|
||||
use std::mem;
|
||||
|
@ -73,9 +73,10 @@ impl Drop for GstDebugDrain {
|
|||
}
|
||||
|
||||
impl Drain for GstDebugDrain {
|
||||
type Error = Never;
|
||||
type Ok = ();
|
||||
type Err = Never;
|
||||
|
||||
fn log(&self, record: &Record, _: &OwnedKeyValueList) -> Result<(), Never> {
|
||||
fn log(&self, record: &Record, _: &OwnedKVList) -> Result<(), Never> {
|
||||
let level = match record.level() {
|
||||
Level::Critical | Level::Error => gst::GST_LEVEL_ERROR,
|
||||
Level::Warning => gst::GST_LEVEL_WARNING,
|
||||
|
@ -95,7 +96,7 @@ impl Drain for GstDebugDrain {
|
|||
// TODO: Probably want to include module?
|
||||
let function_cstr = CString::new(record.function().as_bytes()).unwrap();
|
||||
|
||||
let message_cstr = CString::new(fmt::format(record.msg()).as_bytes()).unwrap();
|
||||
let message_cstr = CString::new(fmt::format(*record.msg()).as_bytes()).unwrap();
|
||||
|
||||
unsafe {
|
||||
let element = gobject::g_weak_ref_get(&*self.element as *const gobject::GWeakRef as
|
||||
|
|
|
@ -19,7 +19,7 @@ use std::sync::atomic::{AtomicBool, Ordering};
|
|||
|
||||
use url::Url;
|
||||
|
||||
use slog::*;
|
||||
use slog::Logger;
|
||||
|
||||
use utils::*;
|
||||
use error::*;
|
||||
|
@ -81,7 +81,7 @@ impl SinkWrapper {
|
|||
"rssink",
|
||||
0,
|
||||
"Rust sink base class"),
|
||||
None),
|
||||
o!()),
|
||||
uri: Mutex::new((None, false)),
|
||||
uri_validator: sink.uri_validator(),
|
||||
sink: Mutex::new(sink),
|
||||
|
|
|
@ -19,7 +19,7 @@ use std::sync::atomic::{AtomicBool, Ordering};
|
|||
|
||||
use url::Url;
|
||||
|
||||
use slog::*;
|
||||
use slog::Logger;
|
||||
|
||||
use plugin::Plugin;
|
||||
use utils::*;
|
||||
|
@ -84,7 +84,7 @@ impl SourceWrapper {
|
|||
"rssrc",
|
||||
0,
|
||||
"Rust source base class"),
|
||||
None),
|
||||
o!()),
|
||||
uri: Mutex::new((None, false)),
|
||||
uri_validator: source.uri_validator(),
|
||||
source: Mutex::new(source),
|
||||
|
|
Loading…
Reference in a new issue