ges-audio-track.c 3.07 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
/* GStreamer Editing Services
 * Copyright (C) <2013> Thibault Saunier <thibault.saunier@collabora.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 */

/**
 * SECTION: ges-audio-track:
 * @short_description: A standard GESTrack for raw audio
 */

#define DEFAULT_CAPS "audio/x-raw"

27
#include "ges-internal.h"
28 29 30
#include "ges-smart-adder.h"
#include "ges-audio-track.h"

31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
struct _GESAudioTrackPrivate
{
  gpointer nothing;
};

G_DEFINE_TYPE (GESAudioTrack, ges_audio_track, GES_TYPE_TRACK);

/****************************************************
 *              Private methods and utils           *
 ****************************************************/
static GstElement *
create_element_for_raw_audio_gap (GESTrack * track)
{
  GstElement *elem;

  elem = gst_element_factory_make ("audiotestsrc", NULL);
  g_object_set (elem, "wave", 4, NULL);

  return elem;
}


/****************************************************
 *              GObject vmethods implementations    *
 ****************************************************/

static void
ges_audio_track_init (GESAudioTrack * self)
{
  self->priv = G_TYPE_INSTANCE_GET_PRIVATE ((self), GES_TYPE_AUDIO_TRACK,
      GESAudioTrackPrivate);
}

static void
ges_audio_track_finalize (GObject * object)
{
  /* TODO: Add deinitalization code here */

  G_OBJECT_CLASS (ges_audio_track_parent_class)->finalize (object);
}

static void
ges_audio_track_class_init (GESAudioTrackClass * klass)
{
  GObjectClass *object_class = G_OBJECT_CLASS (klass);
/*   GESTrackClass *parent_class = GES_TRACK_CLASS (klass);
 */

  g_type_class_add_private (klass, sizeof (GESAudioTrackPrivate));

  object_class->finalize = ges_audio_track_finalize;
82 83

  GES_TRACK_CLASS (klass)->get_mixing_element = ges_smart_adder_new;
84 85 86 87 88 89 90 91 92 93 94 95 96
}

/****************************************************
 *              API implementation                  *
 ****************************************************/
/**
 * ges_audio_track_new:
 *
 * Creates a new #GESAudioTrack of type #GES_TRACK_TYPE_AUDIO and with generic
 * raw audio caps ("audio/x-raw");
 *
 * Returns: A new #GESTrack
 */
97
GESAudioTrack *
98 99
ges_audio_track_new (void)
{
100
  GESAudioTrack *ret;
101 102 103 104 105 106 107 108 109 110
  GstCaps *caps = gst_caps_from_string (DEFAULT_CAPS);

  ret = g_object_new (GES_TYPE_AUDIO_TRACK, "caps", caps,
      "track-type", GES_TRACK_TYPE_AUDIO, NULL);

  ges_track_set_create_element_for_gap_func (GES_TRACK (ret),
      create_element_for_raw_audio_gap);

  return ret;
}