1 /*
   2  * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 #ifndef __AVCDECODER_H__
  27 #define __AVCDECODER_H__
  28 
  29 #include <gst/gst.h>
  30 #include <CoreFoundation/CoreFoundation.h>
  31 #include <VideoDecodeAcceleration/VDADecoder.h>
  32 
  33 G_BEGIN_DECLS
  34 
  35 #define TYPE_AVCDECODER \
  36 (avcdecoder_get_type())
  37 #define AVCDECODER(obj) \
  38 (G_TYPE_CHECK_INSTANCE_CAST((obj),TYPE_AVCDECODER,AvcDecoder))
  39 #define AVCDECODER_CLASS(klass) \
  40 (G_TYPE_CHECK_CLASS_CAST((klass),TYPE_AVCDECODER,AvcDecoderClass))
  41 #define IS_AVCDECODER(obj) \
  42 (G_TYPE_CHECK_INSTANCE_TYPE((obj),TYPE_AVCDECODER))
  43 #define IS_AVCDECODER_CLASS(klass) \
  44 (G_TYPE_CHECK_CLASS_TYPE((klass),TYPE_AVCDECODER))
  45 
  46 typedef struct _AvcDecoder      AvcDecoder;
  47 typedef struct _AvcDecoderClass AvcDecoderClass;
  48 
  49 struct _AvcDecoder
  50 {
  51     GstElement element;
  52 
  53     GstPad *sinkpad;        // input port for MPEG-4 audio
  54     GstPad *srcpad;         // output port for PCM samples
  55 
  56     VDADecoder decoder;     // the Video Decode Acceleration framework decoder reference
  57     VDADecoderOutputCallback* outputCallback; // the callback which receives decoded frames
  58 
  59     gboolean is_initialized; // whether this structure is initialized
  60     gboolean is_newsegment; // whether a new segment has been received
  61     volatile gboolean is_flushing; // element is between flush start and stop
  62     gboolean is_stride_set; // whether the output buffer stride has been set
  63 
  64     gint64 segment_start; // the start time of the segment
  65 
  66     GstClockTime frame_duration; // the duration of a single video frame (nsec)
  67 
  68     GQueue* ordered_frames;      // decoded frames sorted into order of increasign time stamp
  69     GMutex* mutex;    // synchronize frames queue access
  70 
  71     GstClockTime previous_timestamp; // the timestamp of the most recent preceding frame
  72     GstClockTime timestamp_ceil;     // increment above previous timestamp in which frame should fall
  73 };
  74 
  75 struct _AvcDecoderClass
  76 {
  77     GstElementClass parent_class;
  78 };
  79 
  80 GType avcdecoder_get_type (void);
  81 gboolean avcdecoder_plugin_init (GstPlugin * avcdecoder);
  82 
  83 G_END_DECLS
  84 
  85 #endif /* __AVCDECODER_H__ */