~mfisch/brasero/update-to-3.8.0

« back to all changes in this revision

Viewing changes to src/plugins/transcode/burn-transcode.c

  • Committer: Bazaar Package Importer
  • Author(s): Pedro Fragoso
  • Date: 2008-11-18 11:30:50 UTC
  • mto: (1.4.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: james.westby@ubuntu.com-20081118113050-yhrskmatlel0gzfm
Tags: upstream-0.8.3
ImportĀ upstreamĀ versionĀ 0.8.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
577
577
        brasero_job_get_audio_output (BRASERO_JOB (transcode), &path_dest);
578
578
 
579
579
        if (symlink (path_src, path_dest) == -1) {
 
580
                int errsv = errno;
 
581
 
580
582
                g_set_error (error,
581
583
                             BRASERO_BURN_ERROR,
582
584
                             BRASERO_BURN_ERROR_GENERAL,
583
585
                             _("a symlink could not be created (%s)"),
584
 
                             strerror (errno));
 
586
                             g_strerror (errsv));
585
587
 
586
588
                goto error;
587
589
        }
833
835
                }
834
836
 
835
837
                if (size != b_written) {
 
838
                        int errsv = errno;
 
839
 
836
840
                        g_set_error (error,
837
841
                                     BRASERO_BURN_ERROR,
838
842
                                     BRASERO_BURN_ERROR_GENERAL,
839
843
                                     _("error padding (%s)"),
840
 
                                     strerror (errno));
 
844
                                     g_strerror (errsv));
841
845
                        return -1;
842
846
                }
843
847
        }
1023
1027
        g_free (output);
1024
1028
 
1025
1029
        if (fd == -1) {
 
1030
                int errsv = errno;
 
1031
 
1026
1032
                g_set_error (error,
1027
1033
                             BRASERO_BURN_ERROR,
1028
1034
                             BRASERO_BURN_ERROR_GENERAL,
1029
1035
                             _("error opening file for padding : %s"),
1030
 
                             strerror (errno));
 
1036
                             g_strerror (errsv));
1031
1037
                return FALSE;
1032
1038
        }
1033
1039
 
1348
1354
}
1349
1355
 
1350
1356
static void
 
1357
brasero_transcode_error_on_pad_linking (BraseroTranscode *self)
 
1358
{
 
1359
        BraseroTranscodePrivate *priv;
 
1360
        GstMessage *message;
 
1361
        GstBus *bus;
 
1362
 
 
1363
        priv = BRASERO_TRANSCODE_PRIVATE (self);
 
1364
 
 
1365
        BRASERO_JOB_LOG (self, "Error on pad linking");
 
1366
        message = gst_message_new_error (GST_OBJECT (priv->pipeline),
 
1367
                                         g_error_new (BRASERO_BURN_ERROR,
 
1368
                                                      BRASERO_BURN_ERROR_GENERAL,
 
1369
                                                      "Impossible to link gstreamer plugin pads."),     /* FIXME: translate */
 
1370
                                         "Sent by brasero_metadata_error_on_pad_linking");
 
1371
 
 
1372
        bus = gst_pipeline_get_bus (GST_PIPELINE (priv->pipeline));
 
1373
        gst_bus_post (bus, message);
 
1374
        g_object_unref (bus);
 
1375
}
 
1376
 
 
1377
static void
1351
1378
brasero_transcode_new_decoded_pad_cb (GstElement *decode,
1352
1379
                                      GstPad *pad,
1353
1380
                                      gboolean arg2,
1354
1381
                                      BraseroTranscode *transcode)
1355
1382
{
1356
 
        GstPad *sink;
1357
1383
        GstCaps *caps;
1358
1384
        GstStructure *structure;
1359
1385
        BraseroTranscodePrivate *priv;
1360
1386
 
1361
1387
        priv = BRASERO_TRANSCODE_PRIVATE (transcode);
1362
1388
 
1363
 
        sink = gst_element_get_pad (priv->link, "sink");
1364
 
        if (GST_PAD_IS_LINKED (sink))
1365
 
                return;
 
1389
        BRASERO_JOB_LOG (transcode, "New pad");
1366
1390
 
1367
1391
        /* make sure we only have audio */
1368
1392
        caps = gst_pad_get_caps (pad);
1369
1393
        if (!caps)
1370
1394
                return;
1371
1395
 
1372
 
        /* before linking pads (before any data reach grvolume), send tags */
1373
 
        brasero_transcode_send_volume_event (transcode);
1374
 
 
1375
1396
        structure = gst_caps_get_structure (caps, 0);
1376
 
        if (structure
1377
 
        &&  g_strrstr (gst_structure_get_name (structure), "audio"))
1378
 
                gst_pad_link (pad, sink);
1379
 
 
1380
 
        gst_object_unref (sink);
 
1397
        if (structure) {
 
1398
                if (g_strrstr (gst_structure_get_name (structure), "audio")) {
 
1399
                        GstPad *sink;
 
1400
                        GstElement *queue;
 
1401
                        GstPadLinkReturn res;
 
1402
 
 
1403
                        /* before linking pads (before any data reach grvolume), send tags */
 
1404
                        brasero_transcode_send_volume_event (transcode);
 
1405
 
 
1406
                        /* This is necessary in case there is a video stream
 
1407
                         * (see brasero-metadata.c). we need to queue to avoid
 
1408
                         * a deadlock. */
 
1409
                        queue = gst_element_factory_make ("queue", NULL);
 
1410
                        gst_bin_add (GST_BIN (priv->pipeline), queue);
 
1411
                        if (!gst_element_link (queue, priv->link)) {
 
1412
                                brasero_transcode_error_on_pad_linking (transcode);
 
1413
                                goto end;
 
1414
                        }
 
1415
 
 
1416
                        sink = gst_element_get_pad (queue, "sink");
 
1417
                        if (GST_PAD_IS_LINKED (sink)) {
 
1418
                                brasero_transcode_error_on_pad_linking (transcode);
 
1419
                                goto end;
 
1420
                        }
 
1421
 
 
1422
                        res = gst_pad_link (pad, sink);
 
1423
                        if (res == GST_PAD_LINK_OK)
 
1424
                                gst_element_set_state (queue, GST_STATE_PLAYING);
 
1425
                        else
 
1426
                                brasero_transcode_error_on_pad_linking (transcode);
 
1427
 
 
1428
                        gst_object_unref (sink);
 
1429
                }
 
1430
                /* For video streams add a fakesink (see brasero-metadata.c) */
 
1431
                else if (g_strrstr (gst_structure_get_name (structure), "video")) {
 
1432
                        GstPad *sink;
 
1433
                        GstElement *fakesink;
 
1434
                        GstPadLinkReturn res;
 
1435
 
 
1436
                        BRASERO_JOB_LOG (transcode, "Adding a fakesink for video stream");
 
1437
 
 
1438
                        fakesink = gst_element_factory_make ("fakesink", NULL);
 
1439
                        if (!fakesink) {
 
1440
                                brasero_transcode_error_on_pad_linking (transcode);
 
1441
                                goto end;
 
1442
                        }
 
1443
 
 
1444
                        sink = gst_element_get_static_pad (fakesink, "sink");
 
1445
                        if (!sink) {
 
1446
                                brasero_transcode_error_on_pad_linking (transcode);
 
1447
                                gst_object_unref (fakesink);
 
1448
                                goto end;
 
1449
                        }
 
1450
 
 
1451
                        gst_bin_add (GST_BIN (priv->pipeline), fakesink);
 
1452
                        res = gst_pad_link (pad, sink);
 
1453
 
 
1454
                        if (res == GST_PAD_LINK_OK)
 
1455
                                gst_element_set_state (fakesink, GST_STATE_PLAYING);
 
1456
                        else
 
1457
                                brasero_transcode_error_on_pad_linking (transcode);
 
1458
 
 
1459
                        gst_object_unref (sink);
 
1460
                }
 
1461
        }
 
1462
 
 
1463
end:
1381
1464
        gst_caps_unref (caps);
1382
1465
}
1383
1466