Lines 175-184
gst_ffmpegaudenc_finalize (GObject * object)
Link Here
|
175 |
|
175 |
|
176 |
/* clean up remaining allocated data */ |
176 |
/* clean up remaining allocated data */ |
177 |
av_frame_free (&ffmpegaudenc->frame); |
177 |
av_frame_free (&ffmpegaudenc->frame); |
178 |
gst_ffmpeg_avcodec_close (ffmpegaudenc->context); |
178 |
avcodec_free_context (&ffmpegaudenc->context); |
179 |
gst_ffmpeg_avcodec_close (ffmpegaudenc->refcontext); |
179 |
avcodec_free_context (&ffmpegaudenc->refcontext); |
180 |
av_free (ffmpegaudenc->context); |
|
|
181 |
av_free (ffmpegaudenc->refcontext); |
182 |
|
180 |
|
183 |
G_OBJECT_CLASS (parent_class)->finalize (object); |
181 |
G_OBJECT_CLASS (parent_class)->finalize (object); |
184 |
} |
182 |
} |
Lines 193-201
gst_ffmpegaudenc_start (GstAudioEncoder * encoder)
Link Here
|
193 |
ffmpegaudenc->opened = FALSE; |
191 |
ffmpegaudenc->opened = FALSE; |
194 |
ffmpegaudenc->need_reopen = FALSE; |
192 |
ffmpegaudenc->need_reopen = FALSE; |
195 |
|
193 |
|
196 |
gst_ffmpeg_avcodec_close (ffmpegaudenc->context); |
194 |
avcodec_free_context (&ffmpegaudenc->context); |
197 |
if (avcodec_get_context_defaults3 (ffmpegaudenc->context, |
195 |
ffmpegaudenc->context = avcodec_alloc_context3 (oclass->in_plugin); |
198 |
oclass->in_plugin) < 0) { |
196 |
if (ffmpegaudenc->context == NULL) { |
199 |
GST_DEBUG_OBJECT (ffmpegaudenc, "Failed to set context defaults"); |
197 |
GST_DEBUG_OBJECT (ffmpegaudenc, "Failed to set context defaults"); |
200 |
return FALSE; |
198 |
return FALSE; |
201 |
} |
199 |
} |
Lines 241-250
gst_ffmpegaudenc_set_format (GstAudioEncoder * encoder, GstAudioInfo * info)
Link Here
|
241 |
|
239 |
|
242 |
/* close old session */ |
240 |
/* close old session */ |
243 |
if (ffmpegaudenc->opened) { |
241 |
if (ffmpegaudenc->opened) { |
244 |
gst_ffmpeg_avcodec_close (ffmpegaudenc->context); |
242 |
avcodec_free_context (&ffmpegaudenc->context); |
245 |
ffmpegaudenc->opened = FALSE; |
243 |
ffmpegaudenc->opened = FALSE; |
246 |
if (avcodec_get_context_defaults3 (ffmpegaudenc->context, |
244 |
ffmpegaudenc->context = avcodec_alloc_context3 (oclass->in_plugin); |
247 |
oclass->in_plugin) < 0) { |
245 |
if (ffmpegaudenc->context == NULL) { |
248 |
GST_DEBUG_OBJECT (ffmpegaudenc, "Failed to set context defaults"); |
246 |
GST_DEBUG_OBJECT (ffmpegaudenc, "Failed to set context defaults"); |
249 |
return FALSE; |
247 |
return FALSE; |
250 |
} |
248 |
} |
Lines 286-296
gst_ffmpegaudenc_set_format (GstAudioEncoder * encoder, GstAudioInfo * info)
Link Here
|
286 |
/* open codec */ |
284 |
/* open codec */ |
287 |
if (gst_ffmpeg_avcodec_open (ffmpegaudenc->context, oclass->in_plugin) < 0) { |
285 |
if (gst_ffmpeg_avcodec_open (ffmpegaudenc->context, oclass->in_plugin) < 0) { |
288 |
gst_caps_unref (allowed_caps); |
286 |
gst_caps_unref (allowed_caps); |
289 |
gst_ffmpeg_avcodec_close (ffmpegaudenc->context); |
287 |
avcodec_free_context (&ffmpegaudenc->context); |
290 |
GST_DEBUG_OBJECT (ffmpegaudenc, "avenc_%s: Failed to open FFMPEG codec", |
288 |
GST_DEBUG_OBJECT (ffmpegaudenc, "avenc_%s: Failed to open FFMPEG codec", |
291 |
oclass->in_plugin->name); |
289 |
oclass->in_plugin->name); |
292 |
if (avcodec_get_context_defaults3 (ffmpegaudenc->context, |
290 |
ffmpegaudenc->context = avcodec_alloc_context3 (oclass->in_plugin); |
293 |
oclass->in_plugin) < 0) |
291 |
if (ffmpegaudenc->context == NULL) |
294 |
GST_DEBUG_OBJECT (ffmpegaudenc, "Failed to set context defaults"); |
292 |
GST_DEBUG_OBJECT (ffmpegaudenc, "Failed to set context defaults"); |
295 |
|
293 |
|
296 |
if ((oclass->in_plugin->capabilities & AV_CODEC_CAP_EXPERIMENTAL) && |
294 |
if ((oclass->in_plugin->capabilities & AV_CODEC_CAP_EXPERIMENTAL) && |
Lines 312-321
gst_ffmpegaudenc_set_format (GstAudioEncoder * encoder, GstAudioInfo * info)
Link Here
|
312 |
|
310 |
|
313 |
if (!other_caps) { |
311 |
if (!other_caps) { |
314 |
gst_caps_unref (allowed_caps); |
312 |
gst_caps_unref (allowed_caps); |
315 |
gst_ffmpeg_avcodec_close (ffmpegaudenc->context); |
313 |
avcodec_free_context (&ffmpegaudenc->context); |
316 |
GST_DEBUG ("Unsupported codec - no caps found"); |
314 |
GST_DEBUG ("Unsupported codec - no caps found"); |
317 |
if (avcodec_get_context_defaults3 (ffmpegaudenc->context, |
315 |
ffmpegaudenc->context = avcodec_alloc_context3 (oclass->in_plugin); |
318 |
oclass->in_plugin) < 0) |
316 |
if (ffmpegaudenc->context == NULL) |
319 |
GST_DEBUG_OBJECT (ffmpegaudenc, "Failed to set context defaults"); |
317 |
GST_DEBUG_OBJECT (ffmpegaudenc, "Failed to set context defaults"); |
320 |
return FALSE; |
318 |
return FALSE; |
321 |
} |
319 |
} |
Lines 331-340
gst_ffmpegaudenc_set_format (GstAudioEncoder * encoder, GstAudioInfo * info)
Link Here
|
331 |
|
329 |
|
332 |
if (!gst_audio_encoder_set_output_format (GST_AUDIO_ENCODER (ffmpegaudenc), |
330 |
if (!gst_audio_encoder_set_output_format (GST_AUDIO_ENCODER (ffmpegaudenc), |
333 |
icaps)) { |
331 |
icaps)) { |
334 |
gst_ffmpeg_avcodec_close (ffmpegaudenc->context); |
332 |
avcodec_free_context (&ffmpegaudenc->context); |
335 |
gst_caps_unref (icaps); |
333 |
gst_caps_unref (icaps); |
336 |
if (avcodec_get_context_defaults3 (ffmpegaudenc->context, |
334 |
ffmpegaudenc->context = avcodec_alloc_context3 (oclass->in_plugin); |
337 |
oclass->in_plugin) < 0) |
335 |
if (ffmpegaudenc->context == NULL) |
338 |
GST_DEBUG_OBJECT (ffmpegaudenc, "Failed to set context defaults"); |
336 |
GST_DEBUG_OBJECT (ffmpegaudenc, "Failed to set context defaults"); |
339 |
return FALSE; |
337 |
return FALSE; |
340 |
} |
338 |
} |
Lines 403-410
buffer_info_free (void *opaque, guint8 * data)
Link Here
|
403 |
gst_buffer_unmap (info->buffer, &info->map); |
401 |
gst_buffer_unmap (info->buffer, &info->map); |
404 |
gst_buffer_unref (info->buffer); |
402 |
gst_buffer_unref (info->buffer); |
405 |
} else { |
403 |
} else { |
406 |
av_free (info->ext_data); |
404 |
av_freep (&info->ext_data); |
407 |
av_free (info->ext_data_array); |
405 |
av_freep (&info->ext_data_array); |
408 |
} |
406 |
} |
409 |
g_slice_free (BufferInfo, info); |
407 |
g_slice_free (BufferInfo, info); |
410 |
} |
408 |
} |