comparison libpurple/media/media.c @ 29575:ec5ed142f551

Move set_remote_codec functionality to the Fs2 media backend.
author maiku@pidgin.im
date Mon, 26 Oct 2009 23:26:59 +0000
parents a39696686dd6
children a27e41f373db
comparison
equal deleted inserted replaced
29574:90c48f1e479a 29575:ec5ed142f551
616 result |= PURPLE_MEDIA_SEND_VIDEO; 616 result |= PURPLE_MEDIA_SEND_VIDEO;
617 if (direction & FS_DIRECTION_RECV) 617 if (direction & FS_DIRECTION_RECV)
618 result |= PURPLE_MEDIA_RECV_VIDEO; 618 result |= PURPLE_MEDIA_RECV_VIDEO;
619 } 619 }
620 return result; 620 return result;
621 }
622
623 static FsCodec *
624 purple_media_codec_to_fs(const PurpleMediaCodec *codec)
625 {
626 FsCodec *new_codec;
627 gint id;
628 char *encoding_name;
629 PurpleMediaSessionType media_type;
630 guint clock_rate;
631 guint channels;
632 GList *iter;
633
634 if (codec == NULL)
635 return NULL;
636
637 g_object_get(G_OBJECT(codec),
638 "id", &id,
639 "encoding-name", &encoding_name,
640 "media-type", &media_type,
641 "clock-rate", &clock_rate,
642 "channels", &channels,
643 "optional-params", &iter,
644 NULL);
645
646 new_codec = fs_codec_new(id, encoding_name,
647 purple_media_to_fs_media_type(media_type),
648 clock_rate);
649 new_codec->channels = channels;
650
651 for (; iter; iter = g_list_next(iter)) {
652 PurpleKeyValuePair *param = (PurpleKeyValuePair*)iter->data;
653 fs_codec_add_optional_parameter(new_codec,
654 param->key, param->value);
655 }
656
657 g_free(encoding_name);
658 return new_codec;
659 } 621 }
660 622
661 static PurpleMediaSession* 623 static PurpleMediaSession*
662 purple_media_get_session(PurpleMedia *media, const gchar *sess_id) 624 purple_media_get_session(PurpleMedia *media, const gchar *sess_id)
663 { 625 {
1570 1532
1571 gboolean 1533 gboolean
1572 purple_media_set_send_codec(PurpleMedia *media, const gchar *sess_id, PurpleMediaCodec *codec) 1534 purple_media_set_send_codec(PurpleMedia *media, const gchar *sess_id, PurpleMediaCodec *codec)
1573 { 1535 {
1574 #ifdef USE_VV 1536 #ifdef USE_VV
1575 PurpleMediaSession *session;
1576 FsCodec *fscodec;
1577 GError *err = NULL;
1578
1579 g_return_val_if_fail(PURPLE_IS_MEDIA(media), FALSE); 1537 g_return_val_if_fail(PURPLE_IS_MEDIA(media), FALSE);
1580 1538
1581 session = purple_media_get_session(media, sess_id); 1539 return purple_media_backend_set_send_codec(
1582 1540 media->priv->backend, sess_id, codec);
1583 if (session != NULL)
1584 return FALSE;
1585
1586 fscodec = purple_media_codec_to_fs(codec);
1587 fs_session_set_send_codec(session->session, fscodec, &err);
1588 fs_codec_destroy(fscodec);
1589
1590 if (err) {
1591 purple_debug_error("media", "Error setting send codec\n");
1592 g_error_free(err);
1593 return FALSE;
1594 }
1595 return TRUE;
1596 #else 1541 #else
1597 return FALSE; 1542 return FALSE;
1598 #endif 1543 #endif
1599 } 1544 }
1600 1545