Bug 20772

Summary: Clarify StreamedMedia interface
Product: Telepathy Reporter: Simon McVittie <smcv>
Component: tp-specAssignee: Telepathy bugs list <telepathy-bugs>
Status: RESOLVED FIXED QA Contact: Telepathy bugs list <telepathy-bugs>
Severity: normal    
Priority: medium CC: xclaesse
Version: unspecifiedKeywords: patch
Hardware: Other   
OS: All   
URL: http://people.freedesktop.org/~smcv/telepathy-spec-streaming_errata/spec.html#org.freedesktop.Telepathy.Channel.Type.StreamedMedia
Whiteboard:
i915 platform: i915 features:

Description Simon McVittie 2009-03-20 10:49:14 UTC
Errata for StreamedMedia derived from our experiences implementing the telepathy-qt4 StreamedMedia binding and the telepathy-glib "callable" example CM:

http://git.collabora.co.uk/?p=user/smcv/telepathy-spec-smcv.git;a=shortlog;h=refs/heads/streaming-errata

http://people.freedesktop.org/~smcv/telepathy-spec-streaming_errata/spec.html#org.freedesktop.Telepathy.Channel.Type.StreamedMedia

* b76b7940: Explicitly say that the default state for a newly added stream is Disconnected

* 491ae1a7: Indicate that closing all streams MAY close the channel, but that clients should not use this as the way to hang up calls

* c610252ee: mandate that CMs advertise the real direction by preceding each StreamAdded with StreamDirectionChanged

See the mailing list thread starting at <http://lists.freedesktop.org/archives/telepathy/2009-March/003144.html> for more background.
Comment 1 Simon McVittie 2009-03-20 11:14:55 UTC
*** Bug 15388 has been marked as a duplicate of this bug. ***
Comment 2 Simon McVittie 2009-03-20 11:25:48 UTC
Implementation note: because I specified SDC to be emitted *immediately* before SA, you only have to remember the direction that was in the last SDC signal. Something like this:

static void
my_channel_ui_init (...)
{
  ...

  /* there is no invalid stream ID, so we can't easily distinguish between
   * initial values for these, and having been given those values in the SDC
   * signal - but when a stream is created, it has these values unless we're
   * told otherwise, so that's no problem */
  self->priv->next_stream_id = 0;
  self->priv->next_stream_direction = TP_MEDIA_STREAM_DIRECTION_RECEIVE;
  self->priv->next_stream_pending_send = TP_MEDIA_STREAM_PENDING_LOCAL_SEND;
}

static void
stream_direction_changed_cb (TpChannel *channel,
                             guint id,
                             guint direction,
                             guint pending_send,
                             ...)
{
  stream = g_hash_table_lookup (self->priv->streams, GUINT_TO_POINTER (id));

  if (stream == NULL)
    {
      /* not created yet - we should get StreamAdded next */
      self->priv->next_stream_id = id;
      self->priv->next_stream_direction = direction;
      self->priv->next_stream_pending_send = pending_send;
      return;
    }

  /* else continue as before */
  ...
}

static void
stream_added_cb (TpChannel *channel,
                 guint id,
                 guint media_type,
                 ...)
{
  TpMediaStreamDirection direction = TP_MEDIA_STREAM_DIRECTION_RECEIVE;
  TpMediaStreamPendingSend pending_send = TP_MEDIA_STREAM_PENDING_LOCAL_SEND;

  if (id == self->priv->next_stream_id)
    {
      /* we've just been told the direction for this one */
      direction = self->priv->next_stream_direction;
      pending_send = self->priv->next_stream_pending_send;
    }

  add_stream (..., direction, pending_send,
      TP_MEDIA_STREAM_STATE_DISCONNECTED, ...);
  ...
}
Comment 3 Mikhail Zabaluev 2009-03-20 11:29:48 UTC
(In reply to comment #0)
> * c610252ee: mandate that CMs advertise the real direction by preceding each
> StreamAdded with StreamDirectionChanged

I can't find this commit in gitweb on that repository.

In general, sounds sane.
Comment 4 Simon McVittie 2009-04-13 07:28:17 UTC
Fixed (in a slightly different way) in telepathy-spec 0.17.22

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.