1 /* 2 * GStreamer 3 * Copyright (C) 2016 Vivia Nikolaidou <vivia@toolsonair.com> 4 * 5 * This library is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Library General Public 7 * License as published by the Free Software Foundation; either 8 * version 2 of the License, or (at your option) any later version. 9 * 10 * This library is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * Library General Public License for more details. 14 * 15 * You should have received a copy of the GNU Library General Public 16 * License along with this library; if not, write to the 17 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, 18 * Boston, MA 02110-1301, USA. 19 */ 20 21 #ifndef __GST_AVWAIT_H__ 22 #define __GST_AVWAIT_H__ 23 24 #include <gst/gst.h> 25 #include <gst/audio/audio.h> 26 #include <gst/video/video.h> 27 28 G_BEGIN_DECLS 29 #define GST_TYPE_AVWAIT (gst_avwait_get_type()) 30 #define GST_AVWAIT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_AVWAIT,GstAvWait)) 31 #define GST_IS_AVWAIT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AVWAIT)) 32 #define GST_AVWAIT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass) ,GST_TYPE_AVWAIT,GstAvWaitClass)) 33 #define GST_IS_AVWAIT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass) ,GST_TYPE_AVWAIT)) 34 #define GST_AVWAIT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj) ,GST_TYPE_AVWAIT,GstAvWaitClass)) 35 #define GST_TYPE_AVWAIT_MODE (gst_avwait_mode_get_type ()) 36 typedef struct _GstAvWait GstAvWait; 37 typedef struct _GstAvWaitClass GstAvWaitClass; 38 39 typedef enum 40 { 41 MODE_TIMECODE, 42 MODE_RUNNING_TIME, 43 MODE_VIDEO_FIRST 44 } GstAvWaitMode; 45 46 struct _GstAvWait 47 { 48 GstElement parent; 49 50 GstVideoTimeCode *tc; 51 GstClockTime target_running_time; 52 GstAvWaitMode mode; 53 54 GstVideoTimeCode *end_tc; 55 GstClockTime end_running_time; 56 GstClockTime running_time_to_end_at; 57 58 GstPad *asrcpad, *asinkpad, *vsrcpad, *vsinkpad; 59 60 GstAudioInfo ainfo; 61 GstVideoInfo vinfo; 62 63 GstSegment asegment, vsegment; 64 65 GstClockTime running_time_to_wait_for; 66 GstClockTime last_seen_video_running_time; 67 GstClockTime first_audio_running_time; 68 GstVideoTimeCode *last_seen_tc; 69 70 /* If running_time_to_wait_for has been reached but we are 71 * not recording, audio shouldn't start running. It should 72 * instead start synchronised with the video when we start 73 * recording. Similarly when stopping recording manually vs 74 * when the target timecode has been reached. So we use 75 * different variables for the audio */ 76 GstClockTime audio_running_time_to_wait_for; 77 GstClockTime audio_running_time_to_end_at; 78 79 gboolean video_eos_flag; 80 gboolean audio_eos_flag; 81 gboolean video_flush_flag; 82 gboolean audio_flush_flag; 83 gboolean shutdown_flag; 84 85 gboolean dropping; 86 gboolean recording; 87 gboolean was_recording; 88 gint must_send_end_message; 89 90 GCond cond; 91 GMutex mutex; 92 GCond audio_cond; 93 }; 94 95 struct _GstAvWaitClass 96 { 97 GstElementClass parent_class; 98 }; 99 100 GType gst_avwait_get_type (void); 101 GST_ELEMENT_REGISTER_DECLARE (avwait); 102 103 G_END_DECLS 104 #endif /* __GST_AVWAIT_H__ */ 105