Skip to content

Commit 25d9d69

Browse files
committed
Merge pull request #69 from opentok/archiving_updates
Archiving updates
2 parents 1a7014c + a899daf commit 25d9d69

File tree

19 files changed

+695
-89
lines changed

19 files changed

+695
-89
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,6 @@ docs/_build/
4343

4444
# Virtual env
4545
venv/
46+
47+
# Mac Desktop files
48+
.DS_Store

README.rst

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ OpenTok Python SDK
88
The OpenTok Python SDK lets you generate
99
`sessions <http://tokbox.com/opentok/tutorials/create-session/>`_ and
1010
`tokens <http://tokbox.com/opentok/tutorials/create-token/>`_ for `OpenTok <http://www.tokbox.com/>`_
11-
applications, and `archive <http://www.tokbox.com/platform/archiving>`_ Opentok 2.0 sessions.
12-
13-
If you are updating from a previous version of this SDK, see "Important changes since v2.2.0" below.
11+
applications, and `archive <http://www.tokbox.com/platform/archiving>`_ OpenTok sessions.
1412

1513
Installation using Pip (recommended):
1614
-------------------------------------
@@ -46,11 +44,12 @@ Import the package at the top of any file where you will use it. At the very lea
4644
Creating Sessions
4745
~~~~~~~~~~~~~~~~~
4846

49-
The create an OpenTok Session, use the ``opentok.create_session()`` method. There are two optional
47+
The create an OpenTok Session, use the ``opentok.create_session()`` method. There are three optional
5048
keyword parameters for this method: ``location`` which can be set to a string containing an IP
51-
address, and ``media_mode`` which is a String (defined by the MediaModes class). This method returns
52-
a ``Session`` object. Its ``session_id`` attribute is useful when saving to a persistent store (such
53-
as a database).
49+
address, ``media_mode`` which is a String (defined by the MediaModes class) and ``archive_mode`` which
50+
specifies whether the session will be automatically archived (``always``) or not (``manual``).
51+
This method returns a ``Session`` object. Its ``session_id`` attribute is useful when saving to a persistent
52+
store (such as a database).
5453

5554
.. code:: python
5655
@@ -62,6 +61,9 @@ as a database).
6261
# A session that uses the OpenTok Media Router:
6362
session = opentok.create_session(media_mode=MediaModes.routed)
6463
64+
# An automatically archived session:
65+
session = opentok.create_session(media_mode=MediaModes.routed, archive_mode=ArchiveModes.always)
66+
6567
# A session with a location hint
6668
session = opentok.create_session(location=u'12.34.56.78')
6769
@@ -104,6 +106,27 @@ a Session that has clients connection.
104106
# Store this archive_id in the database
105107
archive_id = archive.id
106108
109+
You can also disable audio or video recording by setting the `has_audio` or `has_video` property of
110+
the `options` parameter to `false`:
111+
112+
.. code:: python
113+
114+
archive = opentok.start_archive(session_id, name=u'Important Presentation', has_video=False)
115+
116+
# Store this archive_id in the database
117+
archive_id = archive.id
118+
119+
By default, all streams are recorded to a single (composed) file. You can record the different
120+
streams in the session to individual files (instead of a single composed file) by setting the
121+
``output_mode`` parameter of the ``opentok.start_archive()`` method `OutputModes.individual`.
122+
123+
.. code:: python
124+
125+
archive = opentok.start_archive(session_id, name=u'Important Presentation', output_mode=OutputModes.individual)
126+
127+
# Store this archive_id in the database
128+
archive_id = archive.id
129+
107130
You can stop the recording of a started Archive using the ``opentok.stop_archive(archive_id)``
108131
method. You can also do this using the ``archive.stop()`` method of an ``Archive`` instance.
109132

@@ -151,6 +174,14 @@ instance of the ``ArchiveList`` class.
151174
# Get the total number of Archives for this API Key
152175
total = archive_list.total
153176
177+
Note that you can also create an automatically archived session, by passing in
178+
``ArchiveModes.always`` as the ``archive_mode`` parameter when you call the
179+
``opentok.create_session()`` method (see "Creating Sessions," above).
180+
181+
For more information on archiving, see the
182+
`OpenTok archiving <https://tokbox.com/opentok/tutorials/archiving/>`_ programming guide.
183+
184+
154185
Samples
155186
-------
156187

@@ -192,8 +223,7 @@ session uses the OpenTok TURN server to relay audio-video streams.
192223

193224
**Changes in v2.2.0:**
194225

195-
This version of the SDK includes support for working with OpenTok 2.0 archives. (This API does not
196-
work with OpenTok 1.0 archives.)
226+
This version of the SDK includes support for working with OpenTok archives.
197227

198228
The OpenTok.create_session() method now includes a media_mode parameter, instead of a p2p parameter.
199229

docs/README.html

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ <h1>OpenTok Python SDK<a class="headerlink" href="#opentok-python-sdk" title="Pe
5050
<p>The OpenTok Python SDK lets you generate
5151
<a class="reference external" href="http://tokbox.com/opentok/tutorials/create-session/">sessions</a> and
5252
<a class="reference external" href="http://tokbox.com/opentok/tutorials/create-token/">tokens</a> for <a class="reference external" href="http://www.tokbox.com/">OpenTok</a>
53-
applications, and <a class="reference external" href="http://www.tokbox.com/platform/archiving">archive</a> Opentok 2.0 sessions.</p>
54-
<p>If you are updating from a previous version of this SDK, see &#8220;Important changes since v2.2.0&#8221; below.</p>
53+
applications, and <a class="reference external" href="http://www.tokbox.com/platform/archiving">archive</a> OpenTok sessions.</p>
5554
<div class="section" id="installation-using-pip-recommended">
5655
<h2>Installation using Pip (recommended):<a class="headerlink" href="#installation-using-pip-recommended" title="Permalink to this headline"></a></h2>
5756
<p>Pip helps manage dependencies for Python projects using the PyPI index. Find more info here:
@@ -80,16 +79,19 @@ <h3>Initializing<a class="headerlink" href="#initializing" title="Permalink to t
8079
</div>
8180
<div class="section" id="creating-sessions">
8281
<h3>Creating Sessions<a class="headerlink" href="#creating-sessions" title="Permalink to this headline"></a></h3>
83-
<p>The create an OpenTok Session, use the <tt class="docutils literal"><span class="pre">opentok.create_session()</span></tt> method. There are two optional
82+
<p>The create an OpenTok Session, use the <tt class="docutils literal"><span class="pre">opentok.create_session()</span></tt> method. There are three optional
8483
keyword parameters for this method: <tt class="docutils literal"><span class="pre">location</span></tt> which can be set to a string containing an IP
85-
address, and <tt class="docutils literal"><span class="pre">media_mode</span></tt> which is a String (defined by the MediaModes class). This method returns
86-
a <tt class="docutils literal"><span class="pre">Session</span></tt> object. Its <tt class="docutils literal"><span class="pre">session_id</span></tt> attribute is useful when saving to a persistent store (such
87-
as a database).</p>
84+
address, <tt class="docutils literal"><span class="pre">media_mode</span></tt> which is a String (defined by the MediaModes class) and <tt class="docutils literal"><span class="pre">archive_mode</span></tt> which
85+
specifies whether the session will be automatically archived (<tt class="docutils literal"><span class="pre">always</span></tt>) or not (<tt class="docutils literal"><span class="pre">manual</span></tt>).
86+
This method returns a <tt class="docutils literal"><span class="pre">Session</span></tt> object. Its <tt class="docutils literal"><span class="pre">session_id</span></tt> attribute is useful when saving to a persistent
87+
store (such as a database).</p>
8888
<div class="code python highlight-python"><div class="highlight"><pre><span class="c"># Create a session that attempts to send streams directly between clients (falling back</span>
8989
<span class="c"># to use the OpenTok TURN server to relay streams if the clients cannot connect):</span>
9090
<span class="n">session</span> <span class="o">=</span> <span class="n">opentok</span><span class="o">.</span><span class="n">create_session</span><span class="p">()</span>
9191
<span class="c"># A session that uses the OpenTok Media Router:</span>
9292
<span class="n">session</span> <span class="o">=</span> <span class="n">opentok</span><span class="o">.</span><span class="n">create_session</span><span class="p">(</span><span class="n">media_mode</span><span class="o">=</span><span class="n">MediaModes</span><span class="o">.</span><span class="n">routed</span><span class="p">)</span>
93+
<span class="c"># An automatically archived session:</span>
94+
<span class="n">session</span> <span class="o">=</span> <span class="n">opentok</span><span class="o">.</span><span class="n">create_session</span><span class="p">(</span><span class="n">media_mode</span><span class="o">=</span><span class="n">MediaModes</span><span class="o">.</span><span class="n">routed</span><span class="p">,</span> <span class="n">archive_mode</span><span class="o">=</span><span class="n">ArchiveModes</span><span class="o">.</span><span class="n">always</span><span class="p">)</span>
9395
<span class="c"># A session with a location hint</span>
9496
<span class="n">session</span> <span class="o">=</span> <span class="n">opentok</span><span class="o">.</span><span class="n">create_session</span><span class="p">(</span><span class="n">location</span><span class="o">=</span><span class="s">u&#39;12.34.56.78&#39;</span><span class="p">)</span>
9597

@@ -125,6 +127,23 @@ <h3>Working with Archives<a class="headerlink" href="#working-with-archives" tit
125127
a Session that has clients connection.</p>
126128
<div class="code python highlight-python"><div class="highlight"><pre><span class="n">archive</span> <span class="o">=</span> <span class="n">opentok</span><span class="o">.</span><span class="n">start_archive</span><span class="p">(</span><span class="n">session_id</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s">u&#39;Important Presentation&#39;</span><span class="p">)</span>
127129

130+
<span class="c"># Store this archive_id in the database</span>
131+
<span class="n">archive_id</span> <span class="o">=</span> <span class="n">archive</span><span class="o">.</span><span class="n">id</span>
132+
</pre></div>
133+
</div>
134+
<p>You can also disable audio or video recording by setting the <cite>has_audio</cite> or <cite>has_video</cite> property of
135+
the <cite>options</cite> parameter to <cite>false</cite>:</p>
136+
<div class="code python highlight-python"><div class="highlight"><pre><span class="n">archive</span> <span class="o">=</span> <span class="n">opentok</span><span class="o">.</span><span class="n">start_archive</span><span class="p">(</span><span class="n">session_id</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s">u&#39;Important Presentation&#39;</span><span class="p">,</span> <span class="n">has_video</span><span class="o">=</span><span class="bp">False</span><span class="p">)</span>
137+
138+
<span class="c"># Store this archive_id in the database</span>
139+
<span class="n">archive_id</span> <span class="o">=</span> <span class="n">archive</span><span class="o">.</span><span class="n">id</span>
140+
</pre></div>
141+
</div>
142+
<p>By default, all streams are recorded to a single (composed) file. You can record the different
143+
streams in the session to individual files (instead of a single composed file) by setting the
144+
<tt class="docutils literal"><span class="pre">output_mode</span></tt> parameter of the <tt class="docutils literal"><span class="pre">opentok.start_archive()</span></tt> method <cite>OutputModes.individual</cite>.</p>
145+
<div class="code python highlight-python"><div class="highlight"><pre><span class="n">archive</span> <span class="o">=</span> <span class="n">opentok</span><span class="o">.</span><span class="n">start_archive</span><span class="p">(</span><span class="n">session_id</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s">u&#39;Important Presentation&#39;</span><span class="p">,</span> <span class="n">output_mode</span><span class="o">=</span><span class="n">OutputModes</span><span class="o">.</span><span class="n">individual</span><span class="p">)</span>
146+
128147
<span class="c"># Store this archive_id in the database</span>
129148
<span class="n">archive_id</span> <span class="o">=</span> <span class="n">archive</span><span class="o">.</span><span class="n">id</span>
130149
</pre></div>
@@ -168,6 +187,11 @@ <h3>Working with Archives<a class="headerlink" href="#working-with-archives" tit
168187
<span class="n">total</span> <span class="o">=</span> <span class="n">archive_list</span><span class="o">.</span><span class="n">total</span>
169188
</pre></div>
170189
</div>
190+
<p>Note that you can also create an automatically archived session, by passing in
191+
<tt class="docutils literal"><span class="pre">ArchiveModes.always</span></tt> as the <tt class="docutils literal"><span class="pre">archive_mode</span></tt> parameter when you call the
192+
<tt class="docutils literal"><span class="pre">opentok.create_session()</span></tt> method (see &#8220;Creating Sessions,&#8221; above).</p>
193+
<p>For more information on archiving, see the
194+
<a class="reference external" href="https://tokbox.com/opentok/tutorials/archiving/">OpenTok archiving</a> programming guide.</p>
171195
</div>
172196
</div>
173197
<div class="section" id="samples">
@@ -203,8 +227,7 @@ <h2>Important changes since v2.2<a class="headerlink" href="#important-changes-s
203227
between each other (peer-to-peer); if clients cannot connect due to firewall restrictions, the
204228
session uses the OpenTok TURN server to relay audio-video streams.</p>
205229
<p><strong>Changes in v2.2.0:</strong></p>
206-
<p>This version of the SDK includes support for working with OpenTok 2.0 archives. (This API does not
207-
work with OpenTok 1.0 archives.)</p>
230+
<p>This version of the SDK includes support for working with OpenTok archives.</p>
208231
<p>The OpenTok.create_session() method now includes a media_mode parameter, instead of a p2p parameter.</p>
209232
<p>For details, see the reference documentation at
210233
&lt;<a class="reference external" href="http://www.tokbox.com/opentok/libraries/server/python/reference/index.html">http://www.tokbox.com/opentok/libraries/server/python/reference/index.html</a>&gt;.</p>

docs/_sources/README.txt

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ OpenTok Python SDK
88
The OpenTok Python SDK lets you generate
99
`sessions <http://tokbox.com/opentok/tutorials/create-session/>`_ and
1010
`tokens <http://tokbox.com/opentok/tutorials/create-token/>`_ for `OpenTok <http://www.tokbox.com/>`_
11-
applications, and `archive <http://www.tokbox.com/platform/archiving>`_ Opentok 2.0 sessions.
12-
13-
If you are updating from a previous version of this SDK, see "Important changes since v2.2.0" below.
11+
applications, and `archive <http://www.tokbox.com/platform/archiving>`_ OpenTok sessions.
1412

1513
Installation using Pip (recommended):
1614
-------------------------------------
@@ -46,11 +44,12 @@ Import the package at the top of any file where you will use it. At the very lea
4644
Creating Sessions
4745
~~~~~~~~~~~~~~~~~
4846

49-
The create an OpenTok Session, use the ``opentok.create_session()`` method. There are two optional
47+
The create an OpenTok Session, use the ``opentok.create_session()`` method. There are three optional
5048
keyword parameters for this method: ``location`` which can be set to a string containing an IP
51-
address, and ``media_mode`` which is a String (defined by the MediaModes class). This method returns
52-
a ``Session`` object. Its ``session_id`` attribute is useful when saving to a persistent store (such
53-
as a database).
49+
address, ``media_mode`` which is a String (defined by the MediaModes class) and ``archive_mode`` which
50+
specifies whether the session will be automatically archived (``always``) or not (``manual``).
51+
This method returns a ``Session`` object. Its ``session_id`` attribute is useful when saving to a persistent
52+
store (such as a database).
5453

5554
.. code:: python
5655

@@ -59,6 +58,8 @@ as a database).
5958
session = opentok.create_session()
6059
# A session that uses the OpenTok Media Router:
6160
session = opentok.create_session(media_mode=MediaModes.routed)
61+
# An automatically archived session:
62+
session = opentok.create_session(media_mode=MediaModes.routed, archive_mode=ArchiveModes.always)
6263
# A session with a location hint
6364
session = opentok.create_session(location=u'12.34.56.78')
6465

@@ -101,6 +102,27 @@ a Session that has clients connection.
101102
# Store this archive_id in the database
102103
archive_id = archive.id
103104

105+
You can also disable audio or video recording by setting the `has_audio` or `has_video` property of
106+
the `options` parameter to `false`:
107+
108+
.. code:: python
109+
110+
archive = opentok.start_archive(session_id, name=u'Important Presentation', has_video=False)
111+
112+
# Store this archive_id in the database
113+
archive_id = archive.id
114+
115+
By default, all streams are recorded to a single (composed) file. You can record the different
116+
streams in the session to individual files (instead of a single composed file) by setting the
117+
``output_mode`` parameter of the ``opentok.start_archive()`` method `OutputModes.individual`.
118+
119+
.. code:: python
120+
121+
archive = opentok.start_archive(session_id, name=u'Important Presentation', output_mode=OutputModes.individual)
122+
123+
# Store this archive_id in the database
124+
archive_id = archive.id
125+
104126
You can stop the recording of a started Archive using the ``opentok.stop_archive(archive_id)``
105127
method. You can also do this using the ``archive.stop()`` method of an ``Archive`` instance.
106128

@@ -148,6 +170,14 @@ instance of the ``ArchiveList`` class.
148170
# Get the total number of Archives for this API Key
149171
total = archive_list.total
150172

173+
Note that you can also create an automatically archived session, by passing in
174+
``ArchiveModes.always`` as the ``archive_mode`` parameter when you call the
175+
``opentok.create_session()`` method (see "Creating Sessions," above).
176+
177+
For more information on archiving, see the
178+
`OpenTok archiving <https://tokbox.com/opentok/tutorials/archiving/>`_ programming guide.
179+
180+
151181
Samples
152182
-------
153183

@@ -189,8 +219,7 @@ session uses the OpenTok TURN server to relay audio-video streams.
189219

190220
**Changes in v2.2.0:**
191221

192-
This version of the SDK includes support for working with OpenTok 2.0 archives. (This API does not
193-
work with OpenTok 1.0 archives.)
222+
This version of the SDK includes support for working with OpenTok archives.
194223

195224
The OpenTok.create_session() method now includes a media_mode parameter, instead of a p2p parameter.
196225

0 commit comments

Comments
 (0)