44
55The OpenTok PHP SDK lets you generate [ sessions] ( http://tokbox.com/opentok/tutorials/create-session/ ) and
66[ tokens] ( http://tokbox.com/opentok/tutorials/create-token/ ) for [ OpenTok] ( http://www.tokbox.com/ )
7- applications, and [ archive] ( http://tokbox.com/#archiving ) OpenTok 2.0 sessions.
8-
9- If you are updating from a previous version of this SDK, see
10- [ Important changes since v2.2.0] ( #important-changes-since-v220 ) .
7+ applications, and [ archive] ( http://tokbox.com/opentok/tutorials/archiving/ ) sessions.
118
129# Installation
1310
@@ -58,20 +55,33 @@ To create an OpenTok Session, use the `createSession($options)` method of the
5855* Setting whether the session will use the OpenTok Media Router or attempt send streams directly
5956 between clients.
6057
58+ * Setting whether the session will automatically create archives (implies use of routed session)
59+
6160* Specifying a location hint.
6261
6362The ` getSessionId() ` method of the ` OpenTok\Session ` instance returns the session ID,
6463which you use to identify the session in the OpenTok client libraries.
6564
6665``` php
6766use OpenTok\MediaMode;
67+ use OpenTok\ArchiveMode;
6868
6969// Create a session that attempts to use peer-to-peer streaming:
70- $session = $openTok->createSession();
70+ $session = $opentok->createSession();
71+
7172// A session that uses the OpenTok Media Router:
72- $session = $openTok->createSession(array( 'mediaMode' => MediaMode::ROUTED ));
73+ $session = $opentok->createSession(array( 'mediaMode' => MediaMode::ROUTED ));
74+
7375// A session with a location hint:
74- $session = $openTok->createSession(array( 'location' => '12.34.56.78' ));
76+ $session = $opentok->createSession(array( 'location' => '12.34.56.78' ));
77+
78+ // An automatically archived session:
79+ $sessionOptions = array(
80+ 'archiveMode' => ArchiveMode::ALWAYS,
81+ 'mediaMode' => MediaMode::ROUTED
82+ );
83+ $session = $opentok->createSession($sessionOptions);
84+
7585
7686// Store this sessionId in the database for later use
7787$sessionId = $session->getSessionId();
@@ -90,7 +100,7 @@ use OpenTok\Session;
90100use OpenTok\Role;
91101
92102// Generate a Token from just a sessionId (fetched from a database)
93- $token = OpenTok ->generateToken($sessionId);
103+ $token = $opentok ->generateToken($sessionId);
94104// Generate a Token by calling the method on the Session (returned from createSession)
95105$token = $session->generateToken();
96106
@@ -106,16 +116,30 @@ $token = $session->generateToken(array(
106116
107117You can start the recording of an OpenTok Session using the ` startArchive($sessionId, $name) ` method
108118of the ` OpenTok\OpenTok ` class. This will return an ` OpenTok\Archive ` instance. The parameter
109- ` $name ` is optional and is used to assign a name for the Archive. Note that you can only start an
119+ ` $archiveOptions ` is an optional array and is used to assign a name, whether to record audio and/or
120+ video, and the desired output mode for the Archive. Note that you can only start an
110121Archive on a Session that has clients connected.
111122
112123``` php
113- $archive = $opentok->startArchive($sessionId, $name);
124+ // Create a simple archive of a session
125+ $archive = $opentok->startArchive($sessionId);
126+
127+
128+ // Create an archive using custom options
129+ $archiveOptions = array(
130+ 'name' => 'Important Presentation', // default: null
131+ 'hasAudio' => true, // default: true
132+ 'hasVideo' => true, // default: true
133+ 'outputMode' => OutputMode::INDIVIDUAL // default: OutputMode::COMPOSED
134+ );
135+ $archive = $opentok->startArchive($sessionId, $archiveOptions);
114136
115137// Store this archiveId in the database for later use
116138$archiveId = $archive->id;
117139```
118140
141+ Setting the output mode to ` OutputMode::INDIVIDUAL ` setting causes each stream in the archive to be recorded to its own individual file. The ` OutputMode::COMPOSED ` setting (the default) causes all streams in the archive are recorded to a single (composed) file.
142+
119143You can stop the recording of a started Archive using the ` stopArchive($archiveId) ` method of the
120144` OpenTok\OpenTok ` object. You can also do this using the ` stop() ` method of the
121145` OpenTok\Archive ` instance.
@@ -158,6 +182,14 @@ $archives = $archiveList->getItems();
158182$totalCount = $archiveList->totalCount();
159183```
160184
185+ Note that you can also create an automatically archived session, by passing in ` ArchiveMode::ALWAYS `
186+ as the ` archiveMode ` key of the ` options ` parameter passed into the ` OpenTok->createSession() `
187+ method (see "Creating Sessions," above).
188+
189+ For more information on archiving, see the
190+ [ OpenTok archiving] ( https://tokbox.com/opentok/tutorials/archiving/ ) programming guide.
191+
192+
161193# Samples
162194
163195There are two sample applications included in this repository. To get going as fast as possible, clone the whole
@@ -194,16 +226,15 @@ session uses the OpenTok TURN server to relay audio-video streams.
194226
195227** Changes in v2.2.0:**
196228
197- This version of the SDK includes support for working with OpenTok 2.0 archives. (This API does not
198- work with OpenTok 1.0 archives.)
229+ This version of the SDK includes support for working with OpenTok archives.
199230
200231The names of many methods of the API have changed. Many method names have
201232changed to use camel case, including the following:
202233
203- * OpenTok. createSession()
204- * OpenTok. generateToken()
234+ * ` \ OpenTok\OpenTok-> createSession()`
235+ * ` \ OpenTok\OpenTok-> generateToken()`
205236
206- Note also that the ` options ` parameter of the ` OpenTok. createSession() ` method has a ` mediaMode `
237+ Note also that the ` options ` parameter of the ` OpenTok-> createSession() ` method has a ` mediaMode `
207238property instead of a ` p2p ` property.
208239
209240The API_Config class has been removed. Store your OpenTok API key and API secret in code outside of the SDK files.
0 commit comments