diff options
Diffstat (limited to 'audio/gstavdtpsink.c')
-rw-r--r-- | audio/gstavdtpsink.c | 53 |
1 files changed, 33 insertions, 20 deletions
diff --git a/audio/gstavdtpsink.c b/audio/gstavdtpsink.c index c956ecbd..25fc1ced 100644 --- a/audio/gstavdtpsink.c +++ b/audio/gstavdtpsink.c @@ -68,7 +68,7 @@ struct bluetooth_data { }; #define IS_SBC(n) (strcmp((n), "audio/x-sbc") == 0) -#define IS_MPEG(n) (strcmp((n), "audio/mpeg") == 0) +#define IS_MPEG_AUDIO(n) (strcmp((n), "audio/mpeg") == 0) enum { PROP_0, @@ -87,8 +87,12 @@ static const GstElementDetails avdtp_sink_details = static GstStaticPadTemplate avdtp_sink_factory = GST_STATIC_PAD_TEMPLATE("sink", GST_PAD_SINK, GST_PAD_ALWAYS, GST_STATIC_CAPS("application/x-rtp, " - "media = (string) \"audio\", " - "encoding-name = (string) \"SBC\";" + "media = (string) \"audio\"," + "payload = (int) " + GST_RTP_PAYLOAD_DYNAMIC_STRING ", " + "clock-rate = (int) { 16000, 32000, " + "44100, 48000 }, " + "encoding-name = (string) \"SBC\"; " "application/x-rtp, " "media = (string) \"audio\", " "payload = (int) " @@ -231,7 +235,7 @@ static gint gst_avdtp_sink_bluetooth_recvmsg_fd(GstAvdtpSink *sink) return 0; } -static gboolean gst_avdtp_sink_init_pkt_conf(GstAvdtpSink *sink, +static gboolean gst_avdtp_sink_init_sbc_pkt_conf(GstAvdtpSink *sink, GstCaps *caps, sbc_capabilities_t *pkt) { @@ -242,9 +246,10 @@ static gboolean gst_avdtp_sink_init_pkt_conf(GstAvdtpSink *sink, GstStructure *structure = gst_caps_get_structure(caps, 0); name = gst_structure_get_name(structure); - /* FIXME only sbc supported here, should suport mp3 */ + if (!(IS_SBC(name))) { - GST_ERROR_OBJECT(sink, "Unsupported format %s", name); + GST_ERROR_OBJECT(sink, "Unexpected format %s, " + "was expecting sbc", name); return FALSE; } @@ -814,7 +819,7 @@ static void gst_avdtp_sink_tag(const GstTagList *taglist, if (!gst_tag_list_get_boolean(taglist, tag, &crc)) { GST_WARNING_OBJECT(self, "failed to get crc tag"); - self->mpeg_stream_changed = TRUE; + return; } gst_avdtp_sink_set_crc(self, crc); @@ -824,7 +829,7 @@ static void gst_avdtp_sink_tag(const GstTagList *taglist, if (!gst_tag_list_get_string(taglist, tag, &channel_mode)) { GST_WARNING_OBJECT(self, "failed to get channel-mode tag"); - self->mpeg_stream_changed = TRUE; + return; } self->channel_mode = gst_avdtp_sink_get_channel_mode( @@ -883,7 +888,6 @@ static gboolean gst_avdtp_sink_start(GstBaseSink *basesink) self->stream_caps = NULL; self->mp3_using_crc = -1; self->channel_mode = -1; - self->mpeg_stream_changed = FALSE; if (!gst_avdtp_sink_get_capabilities(self)) { GST_ERROR_OBJECT(self, "failed to get capabilities " @@ -957,8 +961,17 @@ static gboolean gst_avdtp_sink_init_mp3_pkt_conf( { const GValue *value = NULL; gint rate, layer; + const gchar* name; GstStructure *structure = gst_caps_get_structure(caps, 0); + name = gst_structure_get_name(structure); + + if (!(IS_MPEG_AUDIO(name))) { + GST_ERROR_OBJECT(self, "Unexpected format %s, " + "was expecting mp3", name); + return FALSE; + } + /* layer */ value = gst_structure_get_value(structure, "layer"); layer = g_value_get_int(value); @@ -1016,9 +1029,6 @@ static gboolean gst_avdtp_sink_init_mp3_pkt_conf( /* vbr - we always say its vbr, we don't have how to know it */ pkt->bitrate = 0x8000; - /* bitrate - we don't set anything, its vbr */ - /* FIXME - is this right? */ - return TRUE; } @@ -1044,7 +1054,7 @@ static gboolean gst_avdtp_sink_configure(GstAvdtpSink *self, structure = gst_caps_get_structure(caps, 0); if (gst_structure_has_name(structure, "audio/x-sbc")) - ret = gst_avdtp_sink_init_pkt_conf(self, caps, + ret = gst_avdtp_sink_init_sbc_pkt_conf(self, caps, &req->sbc_capabilities); else if (gst_structure_has_name(structure, "audio/mpeg")) ret = gst_avdtp_sink_init_mp3_pkt_conf(self, caps, @@ -1188,8 +1198,8 @@ static void gst_avdtp_sink_class_init(GstAvdtpSinkClass *klass) "Bluetooth remote device address", NULL, G_PARAM_READWRITE)); - GST_DEBUG_CATEGORY_INIT(avdtp_sink_debug, "a2dpsendersink", 0, - "A2DP sink element"); + GST_DEBUG_CATEGORY_INIT(avdtp_sink_debug, "avdtpsink", 0, + "A2DP headset sink element"); } static void gst_avdtp_sink_init(GstAvdtpSink *self, @@ -1203,6 +1213,11 @@ static void gst_avdtp_sink_init(GstAvdtpSink *self, self->dev_caps = NULL; self->sink_lock = g_mutex_new(); + + /* FIXME this is for not synchronizing with clock, should be tested + * with devices to see the behaviour + gst_base_sink_set_sync(GST_BASE_SINK(self), FALSE); + */ } static GIOError gst_avdtp_sink_audioservice_send( @@ -1325,9 +1340,7 @@ void gst_avdtp_sink_set_crc(GstAvdtpSink *self, gboolean crc) /* test if we already received a different crc */ if (self->mp3_using_crc != -1 && new_crc != self->mp3_using_crc) { - GST_ERROR_OBJECT(self, "crc changed during stream"); - /* FIXME test this, its not being used anywhere */ - self->mpeg_stream_changed = TRUE; + GST_WARNING_OBJECT(self, "crc changed during stream"); return; } self->mp3_using_crc = new_crc; @@ -1342,8 +1355,8 @@ void gst_avdtp_sink_set_channel_mode(GstAvdtpSink *self, new_mode = gst_avdtp_sink_get_channel_mode(mode); if (self->channel_mode != -1 && new_mode != self->channel_mode) { - GST_ERROR_OBJECT(self, "channel mode changed during stream"); - self->mpeg_stream_changed = TRUE; + GST_WARNING_OBJECT(self, "channel mode changed during stream"); + return; } self->channel_mode = new_mode; |