mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-25 16:48:11 +00:00
decklinkvideosrc: Do not append a zero timecode if none is found on the source
If the source doesn't give us timecode information, do not append a zero timecode to the frames. https://bugzilla.gnome.org/show_bug.cgi?id=776900
This commit is contained in:
parent
d9f553bff5
commit
3cb43f35b8
3 changed files with 44 additions and 43 deletions
|
@ -756,8 +756,8 @@ public:
|
||||||
void (*got_video_frame) (GstElement * videosrc,
|
void (*got_video_frame) (GstElement * videosrc,
|
||||||
IDeckLinkVideoInputFrame * frame, GstDecklinkModeEnum mode,
|
IDeckLinkVideoInputFrame * frame, GstDecklinkModeEnum mode,
|
||||||
GstClockTime capture_time, GstClockTime stream_time,
|
GstClockTime capture_time, GstClockTime stream_time,
|
||||||
GstClockTime stream_duration, guint hours, guint minutes, guint seconds,
|
GstClockTime stream_duration, IDeckLinkTimecode *dtc, gboolean
|
||||||
guint frames, BMDTimecodeFlags bflags, gboolean no_signal) = NULL;
|
no_signal) = NULL;
|
||||||
void (*got_audio_packet) (GstElement * videosrc,
|
void (*got_audio_packet) (GstElement * videosrc,
|
||||||
IDeckLinkAudioInputPacket * packet, GstClockTime capture_time,
|
IDeckLinkAudioInputPacket * packet, GstClockTime capture_time,
|
||||||
GstClockTime packet_time, gboolean no_signal) = NULL;
|
GstClockTime packet_time, gboolean no_signal) = NULL;
|
||||||
|
@ -808,10 +808,6 @@ public:
|
||||||
BMDTimeValue stream_time = GST_CLOCK_TIME_NONE;
|
BMDTimeValue stream_time = GST_CLOCK_TIME_NONE;
|
||||||
BMDTimeValue stream_duration = GST_CLOCK_TIME_NONE;
|
BMDTimeValue stream_duration = GST_CLOCK_TIME_NONE;
|
||||||
IDeckLinkTimecode *dtc;
|
IDeckLinkTimecode *dtc;
|
||||||
uint8_t hours, minutes, seconds, frames;
|
|
||||||
BMDTimecodeFlags bflags;
|
|
||||||
|
|
||||||
hours = minutes = seconds = frames = bflags = 0;
|
|
||||||
|
|
||||||
res =
|
res =
|
||||||
video_frame->GetStreamTime (&stream_time, &stream_duration,
|
video_frame->GetStreamTime (&stream_time, &stream_duration,
|
||||||
|
@ -833,27 +829,12 @@ public:
|
||||||
if (res != S_OK) {
|
if (res != S_OK) {
|
||||||
GST_DEBUG_OBJECT (videosrc, "Failed to get timecode: 0x%08x", res);
|
GST_DEBUG_OBJECT (videosrc, "Failed to get timecode: 0x%08x", res);
|
||||||
dtc = NULL;
|
dtc = NULL;
|
||||||
} else {
|
|
||||||
res = dtc->GetComponents (&hours, &minutes, &seconds, &frames);
|
|
||||||
if (res != S_OK) {
|
|
||||||
GST_ERROR ("Could not get components for timecode %p: 0x%08x", dtc,
|
|
||||||
res);
|
|
||||||
hours = 0;
|
|
||||||
minutes = 0;
|
|
||||||
seconds = 0;
|
|
||||||
frames = 0;
|
|
||||||
bflags = 0;
|
|
||||||
} else {
|
|
||||||
GST_DEBUG_OBJECT (videosrc, "Got timecode %02d:%02d:%02d:%02d",
|
|
||||||
hours, minutes, seconds, frames);
|
|
||||||
bflags = dtc->GetFlags ();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* passing dtc reference */
|
||||||
got_video_frame (videosrc, video_frame, mode, capture_time,
|
got_video_frame (videosrc, video_frame, mode, capture_time,
|
||||||
stream_time, stream_duration, (guint8) hours, (guint8) minutes,
|
stream_time, stream_duration, dtc, no_signal);
|
||||||
(guint8) seconds, (guint8) frames, bflags, no_signal);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (got_audio_packet && audiosrc && audio_packet) {
|
if (got_audio_packet && audiosrc && audio_packet) {
|
||||||
|
|
|
@ -209,7 +209,7 @@ struct _GstDecklinkInput {
|
||||||
GMutex lock;
|
GMutex lock;
|
||||||
|
|
||||||
/* Set by the video source */
|
/* Set by the video source */
|
||||||
void (*got_video_frame) (GstElement *videosrc, IDeckLinkVideoInputFrame * frame, GstDecklinkModeEnum mode, GstClockTime capture_time, GstClockTime stream_time, GstClockTime stream_duration, guint hours, guint minutes, guint seconds, guint frames, BMDTimecodeFlags bflags, gboolean no_signal);
|
void (*got_video_frame) (GstElement *videosrc, IDeckLinkVideoInputFrame * frame, GstDecklinkModeEnum mode, GstClockTime capture_time, GstClockTime stream_time, GstClockTime stream_duration, IDeckLinkTimecode *dtc, gboolean no_signal);
|
||||||
/* Configured mode or NULL */
|
/* Configured mode or NULL */
|
||||||
const GstDecklinkMode *mode;
|
const GstDecklinkMode *mode;
|
||||||
BMDPixelFormat format;
|
BMDPixelFormat format;
|
||||||
|
|
|
@ -601,8 +601,8 @@ static void
|
||||||
gst_decklink_video_src_got_frame (GstElement * element,
|
gst_decklink_video_src_got_frame (GstElement * element,
|
||||||
IDeckLinkVideoInputFrame * frame, GstDecklinkModeEnum mode,
|
IDeckLinkVideoInputFrame * frame, GstDecklinkModeEnum mode,
|
||||||
GstClockTime capture_time, GstClockTime stream_time,
|
GstClockTime capture_time, GstClockTime stream_time,
|
||||||
GstClockTime stream_duration, guint hours, guint minutes, guint seconds,
|
GstClockTime stream_duration, IDeckLinkTimecode *dtc,
|
||||||
guint frames, BMDTimecodeFlags bflags, gboolean no_signal)
|
gboolean no_signal)
|
||||||
{
|
{
|
||||||
GstDecklinkVideoSrc *self = GST_DECKLINK_VIDEO_SRC_CAST (element);
|
GstDecklinkVideoSrc *self = GST_DECKLINK_VIDEO_SRC_CAST (element);
|
||||||
GstClockTime timestamp, duration;
|
GstClockTime timestamp, duration;
|
||||||
|
@ -667,23 +667,42 @@ gst_decklink_video_src_got_frame (GstElement * element,
|
||||||
f->mode = mode;
|
f->mode = mode;
|
||||||
f->format = frame->GetPixelFormat ();
|
f->format = frame->GetPixelFormat ();
|
||||||
f->no_signal = no_signal;
|
f->no_signal = no_signal;
|
||||||
bmode = gst_decklink_get_mode (mode);
|
if (dtc != NULL) {
|
||||||
if (bmode->interlaced) {
|
uint8_t hours, minutes, seconds, frames;
|
||||||
flags =
|
BMDTimecodeFlags bflags;
|
||||||
(GstVideoTimeCodeFlags) (flags |
|
HRESULT res;
|
||||||
GST_VIDEO_TIME_CODE_FLAGS_INTERLACED);
|
|
||||||
if (bflags & bmdTimecodeFieldMark)
|
res = dtc->GetComponents (&hours, &minutes, &seconds, &frames);
|
||||||
field_count = 2;
|
if (res != S_OK) {
|
||||||
else
|
GST_ERROR ("Could not get components for timecode %p: 0x%08x", dtc,
|
||||||
field_count = 1;
|
res);
|
||||||
|
f->tc = NULL;
|
||||||
|
} else {
|
||||||
|
bflags = dtc->GetFlags ();
|
||||||
|
GST_DEBUG_OBJECT (self, "Got timecode %02d:%02d:%02d:%02d",
|
||||||
|
hours, minutes, seconds, frames);
|
||||||
|
bmode = gst_decklink_get_mode (mode);
|
||||||
|
if (bmode->interlaced) {
|
||||||
|
flags =
|
||||||
|
(GstVideoTimeCodeFlags) (flags |
|
||||||
|
GST_VIDEO_TIME_CODE_FLAGS_INTERLACED);
|
||||||
|
if (bflags & bmdTimecodeFieldMark)
|
||||||
|
field_count = 2;
|
||||||
|
else
|
||||||
|
field_count = 1;
|
||||||
|
}
|
||||||
|
if (bflags & bmdTimecodeIsDropFrame)
|
||||||
|
flags =
|
||||||
|
(GstVideoTimeCodeFlags) (flags |
|
||||||
|
GST_VIDEO_TIME_CODE_FLAGS_DROP_FRAME);
|
||||||
|
f->tc =
|
||||||
|
gst_video_time_code_new (bmode->fps_n, bmode->fps_d, NULL, flags, hours,
|
||||||
|
minutes, seconds, frames, field_count);
|
||||||
|
}
|
||||||
|
dtc->Release ();
|
||||||
|
} else {
|
||||||
|
f->tc = NULL;
|
||||||
}
|
}
|
||||||
if (bflags & bmdTimecodeIsDropFrame)
|
|
||||||
flags =
|
|
||||||
(GstVideoTimeCodeFlags) (flags |
|
|
||||||
GST_VIDEO_TIME_CODE_FLAGS_DROP_FRAME);
|
|
||||||
f->tc =
|
|
||||||
gst_video_time_code_new (bmode->fps_n, bmode->fps_d, NULL, flags, hours,
|
|
||||||
minutes, seconds, frames, field_count);
|
|
||||||
|
|
||||||
frame->AddRef ();
|
frame->AddRef ();
|
||||||
g_queue_push_tail (&self->current_frames, f);
|
g_queue_push_tail (&self->current_frames, f);
|
||||||
|
@ -798,7 +817,8 @@ gst_decklink_video_src_create (GstPushSrc * bsrc, GstBuffer ** buffer)
|
||||||
GST_BUFFER_FLAG_SET (*buffer, GST_BUFFER_FLAG_GAP);
|
GST_BUFFER_FLAG_SET (*buffer, GST_BUFFER_FLAG_GAP);
|
||||||
GST_BUFFER_TIMESTAMP (*buffer) = f->timestamp;
|
GST_BUFFER_TIMESTAMP (*buffer) = f->timestamp;
|
||||||
GST_BUFFER_DURATION (*buffer) = f->duration;
|
GST_BUFFER_DURATION (*buffer) = f->duration;
|
||||||
gst_buffer_add_video_time_code_meta (*buffer, f->tc);
|
if (f->tc != NULL)
|
||||||
|
gst_buffer_add_video_time_code_meta (*buffer, f->tc);
|
||||||
|
|
||||||
mode = gst_decklink_get_mode (self->mode);
|
mode = gst_decklink_get_mode (self->mode);
|
||||||
if (mode->interlaced && mode->tff)
|
if (mode->interlaced && mode->tff)
|
||||||
|
|
Loading…
Reference in a new issue