gst-plugins-nuvdemux/nuvdemux/gstnuvdemux.h
author rosfran
Wed Nov 15 14:37:59 2006 +0000 (2006-11-15)
branchtrunk
changeset 86 ac9a990a5733
parent 84 8b867c828e89
child 88 2a70ed80ed1a
permissions -rw-r--r--
[svn r87] Minor fix on reading function.
     1 /* GStreamer
     2  * Copyright (C) <2006> Renato Araujo Oliveira Filho <renato.filho@indt.org.br>
     3  *                      Rosfran Borges <rosfran.borges@indt.org.br>
     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., 59 Temple Place - Suite 330,
    18  * Boston, MA 02111-1307, USA.
    19  */
    20 
    21 #ifndef __GST_NUV_DEMUX_H__
    22 #define __GST_NUV_DEMUX_H__
    23 
    24 #include <gst/gst.h>
    25 
    26 #include <gst/base/gstadapter.h>
    27 
    28 G_BEGIN_DECLS
    29 
    30 #define GST_TYPE_NUV_DEMUX \
    31   (gst_nuv_demux_get_type ())
    32 #define GST_NUV_DEMUX(obj) \
    33   (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_NUV_DEMUX, GstNuvDemux))
    34 #define GST_NUV_DEMUX_CLASS(klass) \
    35   (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_NUV_DEMUX, GstNuvDemuxClass))
    36 #define GST_IS_NUV_DEMUX(obj) \
    37   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_NUV_DEMUX))
    38 #define GST_IS_NUV_DEMUX_CLASS(klass) \
    39   (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_NUV_DEMUX))
    40 
    41 #define DEMUX_INDEX_SIZE_MAX (100000)
    42 
    43 /* Indexes (timecodes/offsets) conversion structures */
    44 typedef struct
    45 {
    46     gint64 i_time;
    47     gint64 i_offset;
    48 
    49 } nuv_demux_index_entry;
    50 
    51 typedef struct
    52 {
    53     gint i_idx;
    54     gint i_idx_max;
    55 
    56     nuv_demux_index_entry idx[DEMUX_INDEX_SIZE_MAX];
    57 } nuv_demux_index;
    58 
    59 /* */
    60 typedef struct
    61 {
    62     gchar id[12];       /* "NuppelVideo\0" or "MythTVVideo\0" */
    63     gchar version[5];    /* "x.xx\0" */
    64 
    65     gint  i_width;
    66     gint  i_height;
    67     gint  i_width_desired;
    68     gint  i_height_desired;
    69 
    70     gchar i_mode;            /* P progressive, I interlaced */
    71 
    72     gdouble  d_aspect;       /* 1.0 squared pixel */
    73     gdouble  d_fps;
    74     //fps num/denom
    75     gint     i_fpsn;
    76     gint     i_fpsd;
    77 
    78     gint     i_video_blocks; /* 0 no video, -1 unknown */
    79     gint     i_audio_blocks;
    80     gint     i_text_blocks;
    81 
    82     gint     i_keyframe_distance;
    83 
    84 } nuv_header;
    85 
    86 typedef struct
    87 {
    88     gchar i_type;        /* A: audio, V: video, S: sync; T: test
    89                            R: Seekpoint (string:RTjjjjjjjj)
    90                            D: Extra data for codec */
    91     gchar i_compression; /* V: 0 uncompressed
    92                               1 RTJpeg
    93                               2 RTJpeg+lzo
    94                               N black frame
    95                               L copy last
    96                            A: 0 uncompressed (44100 1-bits, 2ch)
    97                               1 lzo
    98                               2 layer 2
    99                               3 layer 3
   100                               F flac
   101                               S shorten
   102                               N null frame loudless
   103                               L copy last
   104                             S: B audio and vdeo sync point
   105                                A audio sync info (timecode == effective
   106                                     dsp frequency*100)
   107                                V next video sync (timecode == next video
   108                                     frame num)
   109                                S audio,video,text correlation */
   110     gchar i_keyframe;    /* 0 keyframe, else no no key frame */
   111     guint8 i_filters;  /* 0x01: gauss 5 pixel (8,2,2,2,2)/16
   112                            0x02: gauss 5 pixel (8,1,1,1,1)/12
   113                            0x04: cartoon filter */
   114 
   115     gint32 i_timecode;     /* ms */
   116 
   117     gint i_length;       /* V,A,T: length of following data
   118                            S: length of packet correl */
   119 } nuv_frame_header;
   120 
   121 /* FIXME Not sure of this one */
   122 typedef struct
   123 {
   124     gint             i_version;
   125     guint32		     i_video_fcc;
   126 
   127     guint32		     i_audio_fcc;
   128     gint             i_audio_sample_rate;
   129     gint             i_audio_bits_per_sample;
   130     gint             i_audio_channels;
   131     gint             i_audio_compression_ratio;
   132     gint             i_audio_quality;
   133     gint             i_rtjpeg_quality;
   134     gint             i_rtjpeg_luma_filter;
   135     gint             i_rtjpeg_chroma_filter;
   136     gint             i_lavc_bitrate;
   137     gint             i_lavc_qmin;
   138     gint             i_lavc_qmax;
   139     gint             i_lavc_maxqdiff;
   140     gint64         	 i_seekable_offset;
   141     gint64           i_keyframe_adjust_offset;
   142 
   143 } nuv_extended_header;
   144 
   145 typedef enum {
   146   GST_NUV_DEMUX_START,
   147   GST_NUV_DEMUX_HEADER_DATA,
   148   GST_NUV_DEMUX_EXTRA_DATA,
   149   GST_NUV_DEMUX_MPEG_DATA,
   150   GST_NUV_DEMUX_EXTEND_HEADER,
   151   GST_NUV_DEMUX_EXTEND_HEADER_DATA,
   152   GST_NUV_DEMUX_FRAME_HEADER,
   153   GST_NUV_DEMUX_MOVI,
   154   GST_NUV_DEMUX_INVALID_DATA
   155 } GstNuvDemuxState;
   156 
   157 typedef struct _GstNuvDemux {
   158   GstElement     parent;
   159 
   160   guint         mode;
   161   GstAdapter    *adapter; 
   162 
   163   /* pads */
   164   GstPad        *sinkpad;
   165   GstPad        *src_video_pad;  
   166   GstPad        *src_audio_pad;
   167 
   168   /* NUV decoding state */
   169   GstNuvDemuxState  state;
   170   guint64           duration;
   171   guint64           offset;
   172   guint64           time_offset;
   173   guint64           last_frame_time;
   174   gboolean          new_audio_segment;
   175   gboolean          new_video_segment;
   176 
   177   /* Mpeg ExtraData */
   178   guint64       mpeg_data_size;
   179   GstBuffer     *mpeg_buffer;
   180   
   181   nuv_header *h;
   182   nuv_extended_header *eh;
   183   nuv_frame_header *fh;
   184   
   185   /* FIXME: change these fields to private struct */
   186   /* first data buffer received, should sent new_segment */
   187 } GstNuvDemux;
   188 
   189 typedef struct _GstNuvDemuxClass {
   190   GstElementClass parent_class;
   191 } GstNuvDemuxClass;
   192 
   193 GType           gst_nuv_demux_get_type          (void);
   194 
   195 G_END_DECLS
   196 
   197 #endif /* __GST_NUV_DEMUX_H__ */