gst-plugins-nuvdemux/src/gstnuvdemux.h
author rosfran
Mon Nov 06 22:59:51 2006 +0000 (2006-11-06)
branchtrunk
changeset 69 f7c91518d8f4
parent 60 98fa2109e716
child 73 959df0ca7621
permissions -rw-r--r--
[svn r70] Renamed these remote_encoder source files to recorder.
     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 /* Indexes (timecodes/offsets) conversion structures */
    42 typedef struct
    43 {
    44     gint64 i_time;
    45     gint64 i_offset;
    46 
    47 } nuv_demux_index_entry;
    48 
    49 typedef struct
    50 {
    51     gint i_idx;
    52     gint i_idx_max;
    53 
    54     nuv_demux_index_entry *idx;
    55 } nuv_demux_index;
    56 
    57 /* */
    58 typedef struct
    59 {
    60     gchar id[12];       /* "NuppelVideo\0" or "MythTVVideo\0" */
    61     gchar version[5];    /* "x.xx\0" */
    62 
    63     gint  i_width;
    64     gint  i_height;
    65     gint  i_width_desired;
    66     gint  i_height_desired;
    67 
    68     gchar i_mode;            /* P progressive, I interlaced */
    69 
    70     gdouble  d_aspect;       /* 1.0 squared pixel */
    71     gdouble  d_fps;
    72 
    73     gint     i_video_blocks; /* 0 no video, -1 unknown */
    74     gint     i_audio_blocks;
    75     gint     i_text_blocks;
    76 
    77     gint     i_keyframe_distance;
    78 
    79 } nuv_header;
    80 
    81 typedef struct
    82 {
    83     gchar i_type;        /* A: audio, V: video, S: sync; T: test
    84                            R: Seekpoint (string:RTjjjjjjjj)
    85                            D: Extra data for codec */
    86     gchar i_compression; /* V: 0 uncompressed
    87                               1 RTJpeg
    88                               2 RTJpeg+lzo
    89                               N black frame
    90                               L copy last
    91                            A: 0 uncompressed (44100 1-bits, 2ch)
    92                               1 lzo
    93                               2 layer 2
    94                               3 layer 3
    95                               F flac
    96                               S shorten
    97                               N null frame loudless
    98                               L copy last
    99                             S: B audio and vdeo sync point
   100                                A audio sync info (timecode == effective
   101                                     dsp frequency*100)
   102                                V next video sync (timecode == next video
   103                                     frame num)
   104                                S audio,video,text correlation */
   105     gchar i_keyframe;    /* 0 keyframe, else no no key frame */
   106     guint8 i_filters;  /* 0x01: gauss 5 pixel (8,2,2,2,2)/16
   107                            0x02: gauss 5 pixel (8,1,1,1,1)/12
   108                            0x04: cartoon filter */
   109 
   110     gint i_timecode;     /* ms */
   111 
   112     gint i_length;       /* V,A,T: length of following data
   113                            S: length of packet correl */
   114 } nuv_frame_header;
   115 
   116 /* FIXME Not sure of this one */
   117 typedef struct
   118 {
   119     gint             i_version;
   120     guint32		     i_video_fcc;
   121 
   122     guint32		     i_audio_fcc;
   123     gint             i_audio_sample_rate;
   124     gint             i_audio_bits_per_sample;
   125     gint             i_audio_channels;
   126     gint             i_audio_compression_ratio;
   127     gint             i_audio_quality;
   128     gint             i_rtjpeg_quality;
   129     gint             i_rtjpeg_luma_filter;
   130     gint             i_rtjpeg_chroma_filter;
   131     gint             i_lavc_bitrate;
   132     gint             i_lavc_qmin;
   133     gint             i_lavc_qmax;
   134     gint             i_lavc_maxqdiff;
   135     gint64         	 i_seekable_offset;
   136     gint64           i_keyframe_adjust_offset;
   137 
   138 } nuv_extended_header;
   139 
   140 typedef enum {
   141   GST_NUV_DEMUX_START,
   142   GST_NUV_DEMUX_HEADER_DATA,
   143   GST_NUV_DEMUX_EXTRA_DATA,
   144   GST_NUV_DEMUX_MPEG_DATA,
   145   GST_NUV_DEMUX_EXTEND_HEADER,
   146   GST_NUV_DEMUX_EXTEND_HEADER_DATA,
   147   GST_NUV_DEMUX_FRAME_HEADER,
   148   GST_NUV_DEMUX_MOVI,
   149   GST_NUV_DEMUX_INVALID_DATA
   150 } GstNuvDemuxState;
   151 
   152 typedef struct _GstNuvDemux {
   153   GstElement     parent;
   154 
   155   guint         mode;
   156   GstAdapter    *adapter; 
   157   guint64       video_offset;
   158   guint64       audio_offset;
   159 
   160   /* pads */
   161   
   162   GstPad        *sinkpad;
   163   GstPad        *src_video_pad;  
   164   GstPad        *src_audio_pad;
   165   gboolean      first_video;
   166   gboolean      first_audio;
   167 
   168   /* NUV decoding state */
   169   GstNuvDemuxState state;
   170   guint64        offset;
   171 
   172   /* Mpeg ExtraData */
   173   guint64       mpeg_data_size;
   174   GstBuffer     *mpeg_buffer;
   175   
   176   nuv_header *h;
   177   nuv_extended_header *eh;
   178   nuv_frame_header *fh;
   179   
   180   /* index */
   181   nuv_demux_index *index_entries;
   182   guint          index_size;
   183   guint64        index_offset;
   184   guint          current_entry;
   185 
   186 } GstNuvDemux;
   187 
   188 typedef struct _GstNuvDemuxClass {
   189   GstElementClass parent_class;
   190 } GstNuvDemuxClass;
   191 
   192 GType           gst_nuv_demux_get_type          (void);
   193 
   194 G_END_DECLS
   195 
   196 #endif /* __GST_NUV_DEMUX_H__ */