Improve logging #14

This commit is contained in:
Daniel Vilar 2018-12-11 12:26:50 +01:00
parent 678c5876de
commit 3e38042d7f
2 changed files with 18 additions and 7 deletions

View file

@ -248,6 +248,7 @@ impl ElementImpl<BaseSrc> for NdiAudioSrc {
ptr::null(),
1000,
);
gst_debug!(self.cat, obj: element, "NDI audio frame received: {:?}", audio_frame);
}
let mut timestamp_data = self.timestamp_data.lock().unwrap();
@ -258,6 +259,7 @@ impl ElementImpl<BaseSrc> for NdiAudioSrc {
receiver.initial_timestamp = audio_frame.timestamp as u64;
timestamp_data.initial_timestamp = audio_frame.timestamp as u64;
}
gst_debug!(self.cat, obj: element, "Setting initial timestamp to {}", timestamp_data.initial_timestamp);
}
}
element.parent_change_state(transition)
@ -342,6 +344,7 @@ impl BaseSrcImpl<BaseSrc> for NdiAudioSrc {
unsafe {
frame_type =
NDIlib_recv_capture_v2(pNDI_recv, ptr::null(), &audio_frame, ptr::null(), 1000);
gst_debug!(self.cat, obj: element, "NDI audio frame received: {:?}", audio_frame);
}
}
@ -404,11 +407,12 @@ impl BaseSrcImpl<BaseSrc> for NdiAudioSrc {
count_frame_none += 1;
continue;
}
gst_element_error!(element, gst::ResourceError::Read, ["NDI frame type none received, assuming that the source closed the stream...."]);
gst_element_error!(element, gst::ResourceError::Read, ["NDI frame type none or error received, assuming that the source closed the stream...."]);
return Err(gst::FlowReturn::CustomError);
}
else{
if frame_type == NDIlib_frame_type_e::NDIlib_frame_type_none && _settings.loss_threshold == 0{
gst_debug!(self.cat, obj: element, "No audio frame received, sending empty buffer");
let buffer = gst::Buffer::with_size(0).unwrap();
return Ok(buffer)
}
@ -420,8 +424,12 @@ impl BaseSrcImpl<BaseSrc> for NdiAudioSrc {
}
}
gst_log!(self.cat, obj: element, "NDI audio frame received: {:?}", (audio_frame));
pts = audio_frame.timestamp as u64 - time;
gst_log!(self.cat, obj: element, "Calculated pts for audio frame: {:?}", (pts));
// We multiply by 2 because is the size in bytes of an i16 variable
let buff_size = (audio_frame.no_samples * 2 * audio_frame.no_channels) as usize;
let mut buffer = gst::Buffer::with_size(buff_size).unwrap();
@ -453,7 +461,7 @@ impl BaseSrcImpl<BaseSrc> for NdiAudioSrc {
NDIlib_util_audio_to_interleaved_16s_v2(&audio_frame, &mut dst);
}
gst_debug!(self.cat, obj: element, "Produced buffer {:?}", buffer);
gst_log!(self.cat, obj: element, "Produced buffer {:?}", buffer);
Ok(buffer)
}

View file

@ -250,6 +250,7 @@ impl ElementImpl<BaseSrc> for NdiVideoSrc {
ptr::null(),
1000,
);
gst_debug!(self.cat, obj: element, "NDI video frame received: {:?}", video_frame);
}
let mut timestamp_data = self.timestamp_data.lock().unwrap();
@ -260,7 +261,7 @@ impl ElementImpl<BaseSrc> for NdiVideoSrc {
receiver.initial_timestamp = video_frame.timestamp as u64;
timestamp_data.initial_timestamp = video_frame.timestamp as u64;
}
gst_debug!(self.cat, obj: element, "Setting initial timestamp to {}", timestamp_data.initial_timestamp);
}
}
element.parent_change_state(transition)
@ -342,6 +343,7 @@ impl BaseSrcImpl<BaseSrc> for NdiVideoSrc {
unsafe {
frame_type =
NDIlib_recv_capture_v2(pNDI_recv, &video_frame, ptr::null(), ptr::null(), 1000);
gst_debug!(self.cat, obj: element, "NDI video frame received: {:?}", video_frame);
}
}
@ -407,11 +409,12 @@ impl BaseSrcImpl<BaseSrc> for NdiVideoSrc {
count_frame_none += 1;
continue;
}
gst_element_error!(element, gst::ResourceError::Read, ["NDI frame type none received, assuming that the source closed the stream...."]);
gst_element_error!(element, gst::ResourceError::Read, ["NDI frame type none or error received, assuming that the source closed the stream...."]);
return Err(gst::FlowReturn::CustomError);
}
else{
if frame_type == NDIlib_frame_type_e::NDIlib_frame_type_none && _settings.loss_threshold == 0{
gst_debug!(self.cat, obj: element, "No video frame received, sending empty buffer");
let buffer = gst::Buffer::with_size(0).unwrap();
return Ok(buffer)
}
@ -423,11 +426,11 @@ impl BaseSrcImpl<BaseSrc> for NdiVideoSrc {
}
}
gst_warning!(self.cat, obj: element, "NDI video frame received: {:?}", (video_frame));
gst_log!(self.cat, obj: element, "NDI video frame received: {:?}", (video_frame));
pts = video_frame.timestamp as u64 - time;
gst_warning!(self.cat, obj: element, "Calculated pts for video frame: {:?}", (pts));
gst_log!(self.cat, obj: element, "Calculated pts for video frame: {:?}", (pts));
let buff_size = (video_frame.yres * video_frame.line_stride_in_bytes) as usize;
let mut buffer = gst::Buffer::with_size(buff_size).unwrap();
@ -455,7 +458,7 @@ impl BaseSrcImpl<BaseSrc> for NdiVideoSrc {
buffer.copy_from_slice(0, &vec).unwrap();
}
gst_debug!(self.cat, obj: element, "Produced buffer {:?}", buffer);
gst_log!(self.cat, obj: element, "Produced buffer {:?}", buffer);
Ok(buffer)
}