Menu

Rate this page:

Thanks for rating this page!

We are always striving to improve our documentation quality, and your feedback is valuable to us. How could this documentation serve you better?

Migrating from 1.x to 2.x - iOS

This guide provides an introduction to the 2.x Programmable Video iOS SDK and a set of guidelines to migrate an application from 1.x to 2.x.

Models

The Video SDK defines a set of objects that represent a multi-party exchange of media. These objects fall into two types of models: Room model and Media model.

Room Model Migration

In Programmable Video 1.x the Room model was comprised of a TVIRoom, a TVILocalParticipant, and one or more TVIParticipant(s). Starting with Programmable Video 2.x, the Room model is now comprised of a TVIRoom, a TVILocalParticipant, and one or more TVIRemoteParticipant(s). The TVILocalParticipant and TVIRemoteParticipant(s) extend the TVIParticipant base class.

Track Publications

In Programmable Video 1.x TVILocalParticipant and TVIParticipant were comprised of TVITrack(s). Programmable Video 2.x introduces the TVITrackPublication base class which is extended by the following objects:

  • TVILocalAudioTrackPublication
  • TVILocalVideoTrackPublication
  • TVILocalDataTrackPublication
  • TVIRemoteAudioTrackPublication
  • TVIRemoteVideoTrackPublication
  • TVIRemoteDataTrackPublication

TVITrackPublication(s) represent the tracks available in a Room comprised of media from TVILocalParticipant and TVIRemoteParticipant(s). TVILocalTrackPublication(s) are available via TVILocalParticipant and TVIRemoteTrackPublication(s) are available via TVIRemoteParticipant. The following graph visualizes the Room model updates from 1.x to 2.x.

Room Model Migration

Media Model Migration

In Programmable Video 1.x the Media model was comprised of a TVITrack base class extended by a TVIAudioTrack and TVIVideoTrack. TVILocalAudioTrack and TVILocalVideoTrack extend TVIAudioTrack and TVIVideoTrack respsectively. The Programmable Video 2.x Media model maintains the same relationship between TVITrack and TVIAudioTrack/TVIVideoTrack and introduces a new implementation of TVITrack: TVIDataTrack (For more on DataTracks, see guide). TVIAudioTrack, TVIVideoTrack, and TVIDataTrack are extended by the following objects:

  • TVILocalAudioTrack
  • TVILocalVideoTrack
  • TVILocalDataTrack
  • TVIRemoteAudioTrack
  • TVIRemoteVideoTrack
  • TVIRemoteDataTrack

The following graph visualizes the Media model updates from 1.x to 2.x.

Media Model Migration

Complete Picture

The following diagrams define all objects and their relationships in the 1.x and 2.x Video SDK.

Video iOS 1.x Object Graph

Video iOS 2.x Object Graph

Updating an Application

This section provides a set of guidelines to migrate an application from Programmable Video iOS SDK 1.x to 2.x.

Reference the 2.0 quickstart when migrating an application from Programmable Video iOS 1.x to 2.x

TVIRemoteParticipantDelegate

Participant events moved from TVIParticipantDelegate to TVIRemoteParticipantDelegate. Reference the API docs for more information on TVIRemoteParticipantDelegate.

Managing Remote Media

In Programmable Video 1.x, applications manage media shared by participants when tracks are added or removed. Starting with Programmable Video 2.x, applications should manage media when tracks are subscribed or unsubscribed. Rendering video when a participant shares a video track provides an example of logic that will need to be updated when migrating to 2.x. In 1.x an application receives [TVIParticipantDelegate participant:addedVideoTrack:] or [TVIParticipantDelegate participant:removedVideoTrack:] delegate callback to render or remove the video track from the UI. In 2.x applications should use [TVIRemoteParticipantDelegate subscribedToVideoTrack:publication:forParticipant:] and [TVIRemoteParticipantDelegte unsubscribedFromVideoTrack:publication:forParticipant:] to perform video rendering logic.

TVILocalParticipant Updates

Applications using TVILocalParticipant to share tracks need to perform the following updates:

  • Change all uses of addAudioTrack: to publishAudioTrack:
  • Change all uses of addVideoTrack: to publishVideoTrack:
  • Change all uses of removeAudioTrack: to unpublishAudioTrack:
  • Change all uses of removeVideoTrack: to unpublishVideoTrack:

TVIParticipant Updates

TVIParticipant remains an object in the SDK, but applications should perform the following updates when migrating to Programmable Video iOS 2.x:

  • Update all references of TVIParticipant to TVIRemoteParticipant
  • Change [TVIRoom participants] to [TVIRoom remoteParticipants]

Need some help?

We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd browsing the Twilio tag on Stack Overflow.

Loading Code Sample...