~ubuntu-branches/ubuntu/quantal/gst-plugins-bad-multiverse0.10/quantal

« back to all changes in this revision

Viewing changes to gst/camerabin/camerabinvideo.c

  • Committer: Bazaar Package Importer
  • Author(s): Onkar Shinde
  • Date: 2010-03-13 22:48:10 UTC
  • mfrom: (1.1.16 upstream)
  • Revision ID: james.westby@ubuntu.com-20100313224810-8l25xl017imj7z4l
Tags: 0.10.18-0ubuntu1
* New upstream bugfix release.
* Relevant upstream fixes
  - 598350 : qtmux with AAC streams (from faac) generate invalid files
  - 607105 : faac doesn't negotiate channel positions correctly
  - 606726 : FAAC bitrate setting has no effect

Show diffs side-by-side

added added

removed removed

Lines of Context:
71
71
#define DEFAULT_MUX "oggmux"
72
72
#define DEFAULT_SINK "filesink"
73
73
 
74
 
#define USE_AUDIO_CONVERSION 1
 
74
#define DEFAULT_FLAGS 0
75
75
 
76
76
enum
77
77
{
187
187
  vid->pending_eos = NULL;
188
188
 
189
189
  vid->mute = ARG_DEFAULT_MUTE;
 
190
  vid->flags = DEFAULT_FLAGS;
190
191
 
191
192
  vid->aud_src_probe_id = 0;
192
193
  vid->vid_src_probe_id = 0;
571
572
 
572
573
  /* Add queue element for video */
573
574
  vid->tee_video_srcpad = gst_element_get_request_pad (vid->tee, "src%d");
 
575
 
574
576
  if (!(vid->video_queue =
575
577
          gst_camerabin_create_and_add_element (vidbin, "queue"))) {
576
578
    goto error;
580
582
  vid->vid_tee_probe_id = gst_pad_add_buffer_probe (vid->tee_video_srcpad,
581
583
      G_CALLBACK (camerabin_video_pad_tee_src0_have_buffer), vid);
582
584
 
583
 
#ifdef USE_TIMEOVERLAY
584
 
  /* Add timeoverlay element to visualize elapsed time for debugging */
585
 
  if (!(gst_camerabin_create_and_add_element (vidbin, "timeoverlay"))) {
586
 
    goto error;
587
 
  }
588
 
#endif
589
 
 
590
585
  /* Add user set or default video encoder element */
591
586
  if (vid->user_vid_enc) {
592
587
    vid->vid_enc = vid->user_vid_enc;
617
612
  g_object_set (G_OBJECT (vid->sink), "location", vid->filename->str, "buffer-mode", 2, /* non buffered io */
618
613
      NULL);
619
614
 
620
 
  /* Add user set or default audio source element */
621
 
  if (!(vid->aud_src = gst_camerabin_setup_default_element (vidbin,
622
 
              vid->user_aud_src, "autoaudiosrc", DEFAULT_AUDIOSRC))) {
623
 
    vid->aud_src = NULL;
624
 
    goto error;
625
 
  } else {
626
 
    if (!gst_camerabin_add_element (vidbin, vid->aud_src))
627
 
      goto error;
628
 
  }
629
 
 
630
 
  /* Add queue element for audio */
631
 
  if (!(gst_camerabin_create_and_add_element (vidbin, "queue"))) {
632
 
    goto error;
633
 
  }
634
 
 
635
 
  /* Add optional audio conversion and volume elements and
636
 
     raise no errors if adding them fails */
637
 
#ifdef USE_AUDIO_CONVERSION
638
 
  if (!gst_camerabin_try_add_element (vidbin,
639
 
          gst_element_factory_make ("audioconvert", NULL))) {
640
 
    GST_WARNING_OBJECT (vid, "unable to add audio conversion element");
641
 
    /* gst_camerabin_try_add_element() destroyed the element */
642
 
  }
643
 
#endif
644
 
  vid->volume = gst_element_factory_make ("volume", NULL);
645
 
  if (!gst_camerabin_try_add_element (vidbin, vid->volume)) {
646
 
    GST_WARNING_OBJECT (vid, "unable to add volume element");
647
 
    /* gst_camerabin_try_add_element() destroyed the element */
648
 
    vid->volume = NULL;
649
 
  } else {
650
 
    g_object_set (vid->volume, "mute", vid->mute, NULL);
651
 
  }
652
 
 
653
 
  /* Add user set or default audio encoder element */
654
 
  if (vid->user_aud_enc) {
655
 
    vid->aud_enc = vid->user_aud_enc;
656
 
    if (!gst_camerabin_add_element (vidbin, vid->aud_enc)) {
657
 
      goto error;
658
 
    }
659
 
  } else if (!(vid->aud_enc =
660
 
          gst_camerabin_create_and_add_element (vidbin, DEFAULT_AUD_ENC))) {
661
 
    goto error;
662
 
  }
663
 
 
664
 
  /* Link audio part to the muxer */
665
 
  if (!gst_element_link (vid->aud_enc, vid->muxer)) {
666
 
    GST_ELEMENT_ERROR (vid, CORE, NEGOTIATION, (NULL),
667
 
        ("linking audio encoder and muxer failed"));
668
 
    goto error;
669
 
  }
670
 
 
 
615
  if (!(vid->flags & GST_CAMERABIN_FLAG_DISABLE_AUDIO)) {
 
616
    /* Add user set or default audio source element */
 
617
    if (!(vid->aud_src = gst_camerabin_setup_default_element (vidbin,
 
618
                vid->user_aud_src, "autoaudiosrc", DEFAULT_AUDIOSRC))) {
 
619
      vid->aud_src = NULL;
 
620
      goto error;
 
621
    } else {
 
622
      if (!gst_camerabin_add_element (vidbin, vid->aud_src))
 
623
        goto error;
 
624
    }
 
625
 
 
626
    /* Add queue element for audio */
 
627
    if (!(gst_camerabin_create_and_add_element (vidbin, "queue"))) {
 
628
      goto error;
 
629
    }
 
630
 
 
631
    /* Add optional audio conversion and volume elements and
 
632
       raise no errors if adding them fails */
 
633
    if (vid->flags & GST_CAMERABIN_FLAG_AUDIO_CONVERSION) {
 
634
      if (!gst_camerabin_try_add_element (vidbin,
 
635
              gst_element_factory_make ("audioconvert", NULL))) {
 
636
        GST_WARNING_OBJECT (vid, "unable to add audio conversion element");
 
637
        /* gst_camerabin_try_add_element() destroyed the element */
 
638
      }
 
639
    }
 
640
 
 
641
    vid->volume = gst_element_factory_make ("volume", NULL);
 
642
    if (!gst_camerabin_try_add_element (vidbin, vid->volume)) {
 
643
      GST_WARNING_OBJECT (vid, "unable to add volume element");
 
644
      /* gst_camerabin_try_add_element() destroyed the element */
 
645
      vid->volume = NULL;
 
646
    } else {
 
647
      g_object_set (vid->volume, "mute", vid->mute, NULL);
 
648
    }
 
649
 
 
650
    /* Add user set or default audio encoder element */
 
651
    if (vid->user_aud_enc) {
 
652
      vid->aud_enc = vid->user_aud_enc;
 
653
      if (!gst_camerabin_add_element (vidbin, vid->aud_enc)) {
 
654
        goto error;
 
655
      }
 
656
    } else if (!(vid->aud_enc =
 
657
            gst_camerabin_create_and_add_element (vidbin, DEFAULT_AUD_ENC))) {
 
658
      goto error;
 
659
    }
 
660
 
 
661
    /* Link audio part to the muxer */
 
662
    if (!gst_element_link (vid->aud_enc, vid->muxer)) {
 
663
      GST_ELEMENT_ERROR (vid, CORE, NEGOTIATION, (NULL),
 
664
          ("linking audio encoder and muxer failed"));
 
665
      goto error;
 
666
    }
 
667
  }
671
668
  /* Add queue leading out of the video bin and to view finder */
672
669
  vid->tee_vf_srcpad = gst_element_get_request_pad (vid->tee, "src%d");
673
670
  if (!(queue = gst_camerabin_create_and_add_element (vidbin, "queue"))) {
685
682
      G_CALLBACK (gst_camerabin_drop_eos_probe), vid);
686
683
  gst_object_unref (vid_srcpad);
687
684
 
688
 
  pad = gst_element_get_static_pad (vid->aud_src, "src");
689
 
  vid->aud_src_probe_id = gst_pad_add_buffer_probe (pad,
690
 
      G_CALLBACK (camerabin_video_pad_aud_src_have_buffer), vid);
691
 
  gst_object_unref (pad);
692
 
 
 
685
  if (!(vid->flags & GST_CAMERABIN_FLAG_DISABLE_AUDIO)) {
 
686
    pad = gst_element_get_static_pad (vid->aud_src, "src");
 
687
    vid->aud_src_probe_id = gst_pad_add_buffer_probe (pad,
 
688
        G_CALLBACK (camerabin_video_pad_aud_src_have_buffer), vid);
 
689
    gst_object_unref (pad);
 
690
  }
693
691
  GST_DEBUG ("created video elements");
694
692
 
695
693
  return TRUE;
848
846
  GST_OBJECT_UNLOCK (vid);
849
847
}
850
848
 
 
849
void
 
850
gst_camerabin_video_set_flags (GstCameraBinVideo * vid, GstCameraBinFlags flags)
 
851
{
 
852
  GST_DEBUG_OBJECT (vid, "setting video flags: %d", flags);
 
853
  GST_OBJECT_LOCK (vid);
 
854
  vid->flags = flags;
 
855
  GST_OBJECT_UNLOCK (vid);
 
856
}
 
857
 
 
858
 
851
859
gboolean
852
860
gst_camerabin_video_get_mute (GstCameraBinVideo * vid)
853
861
{