• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* GStreamer
2  * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  */
19 
20 #ifndef __GST_FFMPEG_CODECMAP_H__
21 #define __GST_FFMPEG_CODECMAP_H__
22 
23 #include <libavcodec/avcodec.h>
24 #include <libavformat/avformat.h>
25 #include <gst/gst.h>
26 #include <gst/audio/audio.h>
27 #include <gst/video/video.h>
28 
29 /*
30  * _codecid_is_image() returns TRUE for image formats
31  */
32 gboolean
33 gst_ffmpeg_codecid_is_image (enum AVCodecID codec_id);
34 
35 /*
36  * _codecid_to_caps () gets the GstCaps that belongs to
37  * a certain CodecID for a pad with compressed data.
38  */
39 
40 GstCaps *
41 gst_ffmpeg_codecid_to_caps   (enum AVCodecID    codec_id,
42                               AVCodecContext *context,
43                               gboolean        encode);
44 
45 /*
46  * _codectype_to_caps () gets the GstCaps that belongs to
47  * a certain AVMediaType for a pad with uncompressed data.
48  */
49 
50 GstCaps *
51 gst_ffmpeg_codectype_to_audio_caps (AVCodecContext *context,
52                               enum AVCodecID codec_id,
53 				    gboolean encode,
54 				    AVCodec *codec);
55 GstCaps *
56 gst_ffmpeg_codectype_to_video_caps (AVCodecContext *context,
57                               enum AVCodecID codec_id,
58 				    gboolean encode,
59 				    AVCodec *codec);
60 
61 /*
62  * caps_to_codecid () transforms a GstCaps that belongs to
63  * a pad for compressed data to (optionally) a filled-in
64  * context and a codecID.
65  */
66 
67 enum AVCodecID
68 gst_ffmpeg_caps_to_codecid (const GstCaps  *caps,
69                             AVCodecContext *context);
70 
71 /*
72  * caps_with_codecid () transforms a GstCaps for a known codec
73  * ID into a filled-in context.
74  */
75 
76 void
77 gst_ffmpeg_caps_with_codecid (enum AVCodecID    codec_id,
78                               enum AVMediaType  codec_type,
79                               const GstCaps  *caps,
80                               AVCodecContext *context);
81 
82 /*
83  * caps_with_codectype () transforms a GstCaps that belongs to
84  * a pad for uncompressed data to a filled-in context.
85  */
86 
87 void
88 gst_ffmpeg_caps_with_codectype (enum AVMediaType  type,
89                                 const GstCaps  *caps,
90                                 AVCodecContext *context);
91 
92 void
93 gst_ffmpeg_videoinfo_to_context (GstVideoInfo *info,
94 				 AVCodecContext *context);
95 
96 void
97 gst_ffmpeg_audioinfo_to_context (GstAudioInfo *info,
98 				 AVCodecContext *context);
99 
100 GstVideoFormat gst_ffmpeg_pixfmt_to_videoformat (enum AVPixelFormat pixfmt);
101 enum AVPixelFormat gst_ffmpeg_videoformat_to_pixfmt (GstVideoFormat format);
102 
103 GstAudioFormat gst_ffmpeg_smpfmt_to_audioformat (enum AVSampleFormat sample_fmt,
104                                                  GstAudioLayout * layout);
105 
106 /*
107  * _formatid_to_caps () is meant for muxers/demuxers, it
108  * transforms a name (ffmpeg way of ID'ing these, why don't
109  * they have unique numerical IDs?) to the corresponding
110  * caps belonging to that mux-format
111  */
112 
113 GstCaps *
114 gst_ffmpeg_formatid_to_caps (const gchar *format_name);
115 
116 /*
117  * _formatid_get_codecids () can be used to get the codecIDs
118  * (AV_CODEC_ID_NONE-terminated list) that fit that specific
119  * output format.
120  */
121 
122 gboolean
123 gst_ffmpeg_formatid_get_codecids (const gchar *format_name,
124                                   enum AVCodecID ** video_codec_list,
125                                   enum AVCodecID ** audio_codec_list,
126 				  AVOutputFormat * plugin);
127 
128 
129 gboolean
130 gst_ffmpeg_channel_layout_to_gst (guint64 channel_layout, gint channels,
131     GstAudioChannelPosition * pos);
132 
133 #endif /* __GST_FFMPEG_CODECMAP_H__ */
134