Bug #1815 » tvheadend-libav-new-api.patch
tvheadend-new/src/libav.c 2013-11-05 13:49:08.226680742 +0100 | ||
---|---|---|
50 | 50 |
/** |
51 | 51 |
* Translate a component type to a libavcodec id |
52 | 52 |
*/ |
53 |
enum CodecID |
|
53 |
enum AVCodecID
|
|
54 | 54 |
streaming_component_type2codec_id(streaming_component_type_t type) |
55 | 55 |
{ |
56 |
enum CodecID codec_id = CODEC_ID_NONE;
|
|
56 |
enum AVCodecID codec_id = AV_CODEC_ID_NONE;
|
|
57 | 57 | |
58 | 58 |
switch(type) { |
59 | 59 |
case SCT_H264: |
60 |
codec_id = CODEC_ID_H264; |
|
60 |
codec_id = AV_CODEC_ID_H264;
|
|
61 | 61 |
break; |
62 | 62 |
case SCT_MPEG2VIDEO: |
63 |
codec_id = CODEC_ID_MPEG2VIDEO; |
|
63 |
codec_id = AV_CODEC_ID_MPEG2VIDEO;
|
|
64 | 64 |
break; |
65 | 65 |
case SCT_VP8: |
66 |
codec_id = CODEC_ID_VP8; |
|
66 |
codec_id = AV_CODEC_ID_VP8;
|
|
67 | 67 |
break; |
68 | 68 |
case SCT_AC3: |
69 |
codec_id = CODEC_ID_AC3; |
|
69 |
codec_id = AV_CODEC_ID_AC3;
|
|
70 | 70 |
break; |
71 | 71 |
case SCT_EAC3: |
72 |
codec_id = CODEC_ID_EAC3; |
|
72 |
codec_id = AV_CODEC_ID_EAC3;
|
|
73 | 73 |
break; |
74 | 74 |
case SCT_AAC: |
75 |
codec_id = CODEC_ID_AAC; |
|
75 |
codec_id = AV_CODEC_ID_AAC;
|
|
76 | 76 |
break; |
77 | 77 |
case SCT_MPEG2AUDIO: |
78 |
codec_id = CODEC_ID_MP2; |
|
78 |
codec_id = AV_CODEC_ID_MP2;
|
|
79 | 79 |
break; |
80 | 80 |
case SCT_VORBIS: |
81 |
codec_id = CODEC_ID_VORBIS; |
|
81 |
codec_id = AV_CODEC_ID_VORBIS;
|
|
82 | 82 |
break; |
83 | 83 |
case SCT_DVBSUB: |
84 |
codec_id = CODEC_ID_DVB_SUBTITLE; |
|
84 |
codec_id = AV_CODEC_ID_DVB_SUBTITLE;
|
|
85 | 85 |
break; |
86 | 86 |
case SCT_TEXTSUB: |
87 |
codec_id = CODEC_ID_TEXT; |
|
87 |
codec_id = AV_CODEC_ID_TEXT;
|
|
88 | 88 |
break; |
89 | 89 |
case SCT_TELETEXT: |
90 |
codec_id = CODEC_ID_DVB_TELETEXT; |
|
90 |
codec_id = AV_CODEC_ID_DVB_TELETEXT;
|
|
91 | 91 |
break; |
92 | 92 |
default: |
93 |
codec_id = CODEC_ID_NONE; |
|
93 |
codec_id = AV_CODEC_ID_NONE;
|
|
94 | 94 |
break; |
95 | 95 |
} |
96 | 96 | |
... | ... | |
102 | 102 |
* Translate a libavcodec id to a component type |
103 | 103 |
*/ |
104 | 104 |
streaming_component_type_t |
105 |
codec_id2streaming_component_type(enum CodecID id) |
|
105 |
codec_id2streaming_component_type(enum AVCodecID id)
|
|
106 | 106 |
{ |
107 |
streaming_component_type_t type = CODEC_ID_NONE; |
|
107 |
streaming_component_type_t type = AV_CODEC_ID_NONE;
|
|
108 | 108 | |
109 | 109 |
switch(id) { |
110 |
case CODEC_ID_H264: |
|
110 |
case AV_CODEC_ID_H264:
|
|
111 | 111 |
type = SCT_H264; |
112 | 112 |
break; |
113 |
case CODEC_ID_MPEG2VIDEO: |
|
113 |
case AV_CODEC_ID_MPEG2VIDEO:
|
|
114 | 114 |
type = SCT_MPEG2VIDEO; |
115 | 115 |
break; |
116 |
case CODEC_ID_VP8: |
|
116 |
case AV_CODEC_ID_VP8:
|
|
117 | 117 |
type = SCT_VP8; |
118 | 118 |
break; |
119 |
case CODEC_ID_AC3: |
|
119 |
case AV_CODEC_ID_AC3:
|
|
120 | 120 |
type = SCT_AC3; |
121 | 121 |
break; |
122 |
case CODEC_ID_EAC3: |
|
122 |
case AV_CODEC_ID_EAC3:
|
|
123 | 123 |
type = SCT_EAC3; |
124 | 124 |
break; |
125 |
case CODEC_ID_AAC: |
|
125 |
case AV_CODEC_ID_AAC:
|
|
126 | 126 |
type = SCT_AAC; |
127 | 127 |
break; |
128 |
case CODEC_ID_MP2: |
|
128 |
case AV_CODEC_ID_MP2:
|
|
129 | 129 |
type = SCT_MPEG2AUDIO; |
130 | 130 |
break; |
131 |
case CODEC_ID_VORBIS: |
|
131 |
case AV_CODEC_ID_VORBIS:
|
|
132 | 132 |
type = SCT_VORBIS; |
133 | 133 |
break; |
134 |
case CODEC_ID_DVB_SUBTITLE: |
|
134 |
case AV_CODEC_ID_DVB_SUBTITLE:
|
|
135 | 135 |
type = SCT_DVBSUB; |
136 | 136 |
break; |
137 |
case CODEC_ID_TEXT: |
|
137 |
case AV_CODEC_ID_TEXT:
|
|
138 | 138 |
type = SCT_TEXTSUB; |
139 | 139 |
break; |
140 |
case CODEC_ID_DVB_TELETEXT: |
|
140 |
case AV_CODEC_ID_DVB_TELETEXT:
|
|
141 | 141 |
type = SCT_TELETEXT; |
142 | 142 |
break; |
143 |
case CODEC_ID_NONE: |
|
143 |
case AV_CODEC_ID_NONE:
|
|
144 | 144 |
type = SCT_NONE; |
145 | 145 |
break; |
146 | 146 |
default: |
tvheadend-new/src/libav.h 2013-11-05 13:49:08.182680141 +0100 | ||
---|---|---|
19 | 19 |
#ifndef LIBAV_H_ |
20 | 20 |
#define LIBAV_H_ |
21 | 21 | |
22 |
/* Workaround for new libav API */ |
|
23 |
#ifndef AVCODEC_MAX_AUDIO_FRAME_SIZE |
|
24 |
#define AVCODEC_MAX_AUDIO_FRAME_SIZE 192000 |
|
25 |
#endif |
|
22 | 26 | |
23 | 27 |
#include <libavformat/avformat.h> |
24 | 28 |
#include "tvheadend.h" |
25 | 29 | |
26 |
enum CodecID streaming_component_type2codec_id(streaming_component_type_t type); |
|
27 |
streaming_component_type_t codec_id2streaming_component_type(enum CodecID id); |
|
30 |
enum AVCodecID streaming_component_type2codec_id(streaming_component_type_t type);
|
|
31 |
streaming_component_type_t codec_id2streaming_component_type(enum AVCodecID id);
|
|
28 | 32 |
int libav_is_encoder(AVCodec *codec); |
29 | 33 |
void libav_init(void); |
30 | 34 |
tvheadend-new/src/plumbing/transcoding.c 2013-11-05 13:49:08.222680687 +0100 | ||
---|---|---|
120 | 120 |
static AVCodec * |
121 | 121 |
transcoder_get_decoder(streaming_component_type_t ty) |
122 | 122 |
{ |
123 |
enum CodecID codec_id; |
|
123 |
enum AVCodecID codec_id;
|
|
124 | 124 |
AVCodec *codec; |
125 | 125 | |
126 | 126 |
codec_id = streaming_component_type2codec_id(ty); |
... | ... | |
149 | 149 |
static AVCodec * |
150 | 150 |
transcoder_get_encoder(streaming_component_type_t ty) |
151 | 151 |
{ |
152 |
enum CodecID codec_id; |
|
152 |
enum AVCodecID codec_id;
|
|
153 | 153 |
AVCodec *codec; |
154 | 154 | |
155 | 155 |
codec_id = streaming_component_type2codec_id(ty); |
... | ... | |
215 | 215 |
if (ictx->codec_id == CODEC_ID_NONE) { |
216 | 216 |
ictx->codec_id = icodec->id; |
217 | 217 | |
218 |
if (avcodec_open(ictx, icodec) < 0) {
|
|
218 |
if (avcodec_open2(ictx, icodec, NULL) ) {
|
|
219 | 219 |
tvhlog(LOG_ERR, "transcode", "Unable to open %s decoder", icodec->name); |
220 | 220 |
ts->ts_index = 0; |
221 | 221 |
goto cleanup; |
... | ... | |
272 | 272 |
if (ictx->codec_id == CODEC_ID_NONE) { |
273 | 273 |
ictx->codec_id = icodec->id; |
274 | 274 | |
275 |
if (avcodec_open(ictx, icodec) < 0) {
|
|
275 |
if (avcodec_open2(ictx, icodec, NULL) ) {
|
|
276 | 276 |
tvhlog(LOG_ERR, "transcode", "Unable to open %s decoder", icodec->name); |
277 | 277 |
ts->ts_index = 0; |
278 | 278 |
goto cleanup; |
... | ... | |
391 | 391 |
if (octx->codec_id == CODEC_ID_NONE) { |
392 | 392 |
octx->codec_id = ocodec->id; |
393 | 393 | |
394 |
if (avcodec_open(octx, ocodec) < 0) {
|
|
394 |
if (avcodec_open2(octx, ocodec, NULL) ) {
|
|
395 | 395 |
tvhlog(LOG_ERR, "transcode", "Unable to open %s encoder", ocodec->name); |
396 | 396 |
ts->ts_index = 0; |
397 | 397 |
goto cleanup; |
... | ... | |
477 | 477 |
if (ictx->codec_id == CODEC_ID_NONE) { |
478 | 478 |
ictx->codec_id = icodec->id; |
479 | 479 | |
480 |
if (avcodec_open(ictx, icodec) < 0) {
|
|
480 |
if (avcodec_open2(ictx, icodec, NULL) ) {
|
|
481 | 481 |
tvhlog(LOG_ERR, "transcode", "Unable to open %s decoder", icodec->name); |
482 | 482 |
ts->ts_index = 0; |
483 | 483 |
goto cleanup; |
... | ... | |
852 | 852 |
ss->sub_icodec = icodec; |
853 | 853 |
ss->sub_ocodec = ocodec; |
854 | 854 | |
855 |
ss->sub_ictx = avcodec_alloc_context();
|
|
856 |
ss->sub_octx = avcodec_alloc_context();
|
|
855 |
ss->sub_ictx = avcodec_alloc_context3(NULL);
|
|
856 |
ss->sub_octx = avcodec_alloc_context3(NULL);
|
|
857 | 857 | |
858 | 858 |
ss->sub_ictx->codec_type = AVMEDIA_TYPE_SUBTITLE; |
859 | 859 |
ss->sub_octx->codec_type = AVMEDIA_TYPE_SUBTITLE; |
... | ... | |
944 | 944 |
as->aud_icodec = icodec; |
945 | 945 |
as->aud_ocodec = ocodec; |
946 | 946 | |
947 |
as->aud_ictx = avcodec_alloc_context();
|
|
948 |
as->aud_octx = avcodec_alloc_context();
|
|
947 |
as->aud_ictx = avcodec_alloc_context3(NULL);
|
|
948 |
as->aud_octx = avcodec_alloc_context3(NULL);
|
|
949 | 949 | |
950 | 950 |
as->aud_ictx->codec_type = AVMEDIA_TYPE_AUDIO; |
951 | 951 |
as->aud_octx->codec_type = AVMEDIA_TYPE_AUDIO; |
... | ... | |
1054 | 1054 |
vs->vid_icodec = icodec; |
1055 | 1055 |
vs->vid_ocodec = ocodec; |
1056 | 1056 | |
1057 |
vs->vid_ictx = avcodec_alloc_context();
|
|
1058 |
vs->vid_octx = avcodec_alloc_context();
|
|
1057 |
vs->vid_ictx = avcodec_alloc_context3(NULL);
|
|
1058 |
vs->vid_octx = avcodec_alloc_context3(NULL);
|
|
1059 | 1059 | |
1060 | 1060 |
avcodec_get_context_defaults3(vs->vid_ictx, icodec); |
1061 | 1061 |
avcodec_get_context_defaults3(vs->vid_octx, ocodec); |
- « Previous
- 1
- 2
- Next »