Skip to content

Commit 6f1fbae

Browse files
committed
Merge branch 'v2.2-docs' of https://github.com/jeffswartz/Opentok-Python-SDK into jeffswartz-v2.2-docs
2 parents e04af70 + ea41b1f commit 6f1fbae

16 files changed

+513
-138
lines changed

README.rst

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,11 @@ 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. This version of the SDK also includes support for working with OpenTok 2.0 archives.
11+
applications, and `archive <http://www.tokbox.com/platform/archiving>`_ Opentok 2.0 sessions.
1212

1313

14-
Installation
15-
------------
16-
17-
Pip (recommended):
18-
~~~~~~~~~~~~~~~~~~
14+
Installation using Pip (recommended):
15+
-------------------------------------
1916

2017
Pip helps manage dependencies for Python projects using the PyPI index. Find more info here:
2118
http://www.pip-installer.org/en/latest/
@@ -29,12 +26,6 @@ Next, install the dependencies::
2926

3027
$ pip install -r requirements.txt
3128

32-
Manually:
33-
~~~~~~~~~
34-
35-
Download the latest package zip from the `Releases page
36-
<https://github.com/opentok/Opentok-Python-SDK/releases>`_
37-
3829

3930
Usage
4031
-----
@@ -56,15 +47,17 @@ Creating Sessions
5647

5748
The create an OpenTok Session, use the ``opentok.create_session()`` method. There are two optional
5849
keyword parameters for this method: ``location`` which can be set to a string containing an IP
59-
address, and ``p2p`` which is a boolean. This method returns a ``Session`` object. Its
60-
``session_id`` attribute is useful when saving to a persistent store (e.g. database).
50+
address, and ``media_mode`` which is a String (defined by the MediaModes class). This method returns
51+
a ``Session`` object. Its ``session_id`` attribute is useful when saving to a persistent store (such
52+
as a database).
6153

6254
.. code:: python
6355
64-
# Just a plain Session
56+
# Just a plain Session:
6557
session = opentok.create_session()
66-
# A p2p Session
67-
session = opentok.create_session(p2p=True)
58+
# A Session that attempts to send streams directly between clients (falling back
59+
# to use the OpenTok TURN server to relay streams if the clients cannot connect):
60+
session = opentok.create_session(media_mode=MediaModes.relayed)
6861
# A Session with a location hint
6962
session = opentok.create_session(location=u'12.34.56.78')
7063
@@ -157,7 +150,7 @@ instance of the ``ArchiveList`` class.
157150
Documentation
158151
-------------
159152

160-
Reference documentation is available at <http://www.tokbox.com//opentok/libraries/server/python/reference/index.html> and in the
153+
Reference documentation is available at <http://www.tokbox.com/opentok/libraries/server/python/reference/index.html> and in the
161154
docs directory of the SDK.
162155

163156
Requirements
@@ -179,6 +172,11 @@ Important changes in v2.0
179172
This version of the SDK includes support for working with OpenTok 2.0 archives. (This API does not
180173
work with OpenTok 1.0 archives.)
181174

175+
The OpenTok.create_session() method now includes a media_mode parameter, instead of a p2p parameter.
176+
177+
For details, see the reference documentation at
178+
<http://www.tokbox.com/opentok/libraries/server/python/reference/index.html>.
179+
182180
Development and Contributing
183181
----------------------------
184182

docs/README.html

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ <h3>Navigation</h3>
3232
<li class="right" style="margin-right: 10px">
3333
<a href="genindex.html" title="General Index"
3434
accesskey="I">index</a></li>
35-
<li class="right" >
36-
<a href="py-modindex.html" title="Python Module Index"
37-
>modules</a> |</li>
3835
<li><a href="index.html">OpenTok Python SDK 2.2 2.2.0 documentation</a> &raquo;</li>
3936
</ul>
4037
</div>
@@ -270,9 +267,6 @@ <h3>Navigation</h3>
270267
<li class="right" style="margin-right: 10px">
271268
<a href="genindex.html" title="General Index"
272269
>index</a></li>
273-
<li class="right" >
274-
<a href="py-modindex.html" title="Python Module Index"
275-
>modules</a> |</li>
276270
<li><a href="index.html">OpenTok Python SDK 2.2 2.2.0 documentation</a> &raquo;</li>
277271
</ul>
278272
</div>

docs/_sources/README.txt

Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
==================
2+
OpenTok Python SDK
3+
==================
4+
5+
.. image:: https://travis-ci.org/aoberoi/Opentok-Python-SDK.svg?branch=modernization
6+
:target: https://travis-ci.org/aoberoi/Opentok-Python-SDK
7+
8+
The OpenTok Python SDK lets you generate
9+
`sessions <http://tokbox.com/opentok/tutorials/create-session/>`_ and
10+
`tokens <http://tokbox.com/opentok/tutorials/create-token/>`_ for `OpenTok <http://www.tokbox.com/>`_
11+
applications. This version of the SDK also includes support for working with OpenTok 2.0 archives.
12+
13+
14+
Installation
15+
------------
16+
17+
Pip (recommended):
18+
~~~~~~~~~~~~~~~~~~
19+
20+
Pip helps manage dependencies for Python projects using the PyPI index. Find more info here:
21+
http://www.pip-installer.org/en/latest/
22+
23+
Add the ``opentok`` package as a dependency in your project. The most common way is to add it to your
24+
``requirements.txt`` file::
25+
26+
opentok>=2.2
27+
28+
Next, install the dependencies::
29+
30+
$ pip install -r requirements.txt
31+
32+
Manually:
33+
~~~~~~~~~
34+
35+
Download the latest package zip from the `Releases page
36+
<https://github.com/opentok/Opentok-Python-SDK/releases>`_
37+
38+
39+
Usage
40+
-----
41+
42+
Initializing
43+
~~~~~~~~~~~~
44+
45+
Import the package at the top of any file where you will use it. At the very least you will need the
46+
``OpenTok`` class. Then initialize an OpenTok instance with your own API Key and API Secret.
47+
48+
.. code:: python
49+
50+
from opentok import OpenTok
51+
52+
opentok = OpenTok(api_key, api_secret)
53+
54+
Creating Sessions
55+
~~~~~~~~~~~~~~~~~
56+
57+
The create an OpenTok Session, use the ``opentok.create_session()`` method. There are two optional
58+
keyword parameters for this method: ``location`` which can be set to a string containing an IP
59+
address, and ``p2p`` which is a boolean. This method returns a ``Session`` object. Its
60+
``session_id`` attribute is useful when saving to a persistent store (e.g. database).
61+
62+
.. code:: python
63+
64+
# Just a plain Session
65+
session = opentok.create_session()
66+
# A p2p Session
67+
session = opentok.create_session(p2p=True)
68+
# A Session with a location hint
69+
session = opentok.create_session(location=u'12.34.56.78')
70+
71+
# Store this session ID in the database
72+
session_id = session.session_id
73+
74+
Generating Tokens
75+
~~~~~~~~~~~~~~~~~
76+
77+
Once a Session is created, you can start generating Tokens for clients to use when connecting to it.
78+
You can generate a token either by calling the ``opentok.generate_token(session_id)`` method or by
79+
calling the ``session.generate_token()`` method on a ``Session`` instance after creating it. There
80+
is a set of optional keyword parameters: ``role``, ``expire_time``, and ``data``.
81+
82+
.. code:: python
83+
84+
# Generate a Token from just a session_id (fetched from a database)
85+
token = opentok.generate_token(session_id)
86+
# Generate a Token by calling the method on the Session (returned from create_session)
87+
token = session.generate_token()
88+
89+
from opentok import Roles
90+
# Set some options in a token
91+
token = session.generate_token(role=Roles.moderator,
92+
expire_time=int(time.time()) + 10,
93+
data=u'name=Johnny')
94+
95+
Working with Archives
96+
~~~~~~~~~~~~~~~~~~~~~
97+
98+
You can start the recording of an OpenTok Session using the ``opentok.start_archive(session_id)``
99+
method. This method takes an optional keyword argument ``name`` to assign a name to the archive.
100+
This method will return an ``Archive`` instance. Note that you can only start an Archive on
101+
a Session that has clients connection.
102+
103+
.. code:: python
104+
105+
archive = opentok.start_archive(session_id, name=u'Important Presentation')
106+
107+
# Store this archive_id in the database
108+
archive_id = archive.id
109+
110+
You can stop the recording of a started Archive using the ``opentok.stop_archive(archive_id)``
111+
method. You can also do this using the ``archive.stop()`` method of an ``Archive`` instance.
112+
113+
.. code:: python
114+
115+
# Stop an Archive from an archive_id (fetched from database)
116+
opentok.stop_archive(archive_id)
117+
# Stop an Archive from an instance (returned from opentok.start_archive)
118+
archive.stop()
119+
120+
To get an ``Archive`` instance (and all the information about it) from an archive ID, use the
121+
``opentok.get_archive(archive_id)`` method.
122+
123+
.. code:: python
124+
125+
archive = opentok.get_archive(archive_id)
126+
127+
To delete an Archive, you can call the ``opentok.delete_archive(archive_id)`` method or the
128+
``archive.delete()`` method of an ``Archive`` instance.
129+
130+
.. code:: python
131+
132+
# Delete an Archive from an archive ID (fetched from database)
133+
opentok.delete_archive(archive_id)
134+
# Delete an Archive from an Archive instance (returned from opentok.start_archive or
135+
opentok.get_archive)
136+
archive.delete()
137+
138+
You can also get a list of all the Archives you've created (up to 1000) with your API Key. This is
139+
done using the ``opentok.list_archives()`` method. There are two optional keyword parameters:
140+
``count`` and ``offset``; they can help you paginate through the results. This method returns an
141+
instance of the ``ArchiveList`` class.
142+
143+
.. code:: python
144+
145+
archive_list = opentok.list_archive()
146+
147+
# Get a specific Archive from the list
148+
archive = archive_list.items[i]
149+
150+
# Iterate over items
151+
for archive in iter(archive_list):
152+
pass
153+
154+
# Get the total number of Archives for this API Key
155+
total = archive_list.total
156+
157+
Documentation
158+
-------------
159+
160+
Reference documentation is available at <http://www.tokbox.com//opentok/libraries/server/python/reference/index.html> and in the
161+
docs directory of the SDK.
162+
163+
Requirements
164+
------------
165+
166+
You need an OpenTok API key and API secret, which you can obtain at https://dashboard.tokbox.com/
167+
168+
The OpenTok Python SDK requires Python 2.6, 2.7, 3.2, 3.3, or 3.4
169+
170+
Release Notes
171+
-------------
172+
173+
See the `Releases <https://github.com/opentok/Opentok-Python-SDK/releases>`_ page for details about
174+
each release.
175+
176+
Important changes in v2.0
177+
~~~~~~~~~~~~~~~~~~~~~~~~~
178+
179+
This version of the SDK includes support for working with OpenTok 2.0 archives. (This API does not
180+
work with OpenTok 1.0 archives.)
181+
182+
Development and Contributing
183+
----------------------------
184+
185+
Interested in contributing? We <3 pull requests! File a new
186+
`Issue <https://github.com/opentok/opentok-python-sdk/issues>`_ or take a look at the existing ones.
187+
If you are going to send us a pull request, please try to run the test suite first and also include
188+
tests for your changes.
189+
190+
Support
191+
-------
192+
193+
See http://tokbox.com/opentok/support/ for all our support options.
194+
195+
Find a bug? File it on the `Issues <https://github.com/opentok/opentok-python-sdk/issues>`_ page.
196+
Hint: test cases are really helpful!

docs/_sources/docs/modules.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
opentok
2+
=======
3+
4+
.. toctree::
5+
:maxdepth: 4
6+
7+
opentok

docs/_sources/docs/opentok.txt

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
opentok package
2+
===============
3+
4+
Submodules
5+
----------
6+
7+
opentok.archives module
8+
-----------------------
9+
10+
.. automodule:: opentok.archives
11+
:members:
12+
:undoc-members:
13+
:show-inheritance:
14+
15+
opentok.exceptions module
16+
-------------------------
17+
18+
.. automodule:: opentok.exceptions
19+
:members:
20+
:undoc-members:
21+
:show-inheritance:
22+
23+
opentok.opentok module
24+
----------------------
25+
26+
.. automodule:: opentok.opentok
27+
:members:
28+
:undoc-members:
29+
:show-inheritance:
30+
31+
opentok.session module
32+
----------------------
33+
34+
.. automodule:: opentok.session
35+
:members:
36+
:undoc-members:
37+
:show-inheritance:
38+
39+
opentok.version module
40+
----------------------
41+
42+
.. automodule:: opentok.version
43+
:members:
44+
:undoc-members:
45+
:show-inheritance:
46+
47+
48+
Module contents
49+
---------------
50+
51+
.. automodule:: opentok
52+
:members:
53+
:undoc-members:
54+
:show-inheritance:

docs/_sources/index.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
OpenTok Python SDK 2.2 reference
2+
================================
3+
4+
.. toctree::
5+
:maxdepth: 2
6+
7+
Indices and tables
8+
==================
9+
10+
* :ref:`genindex`
11+
* :ref:`modindex`
12+
* :ref:`search`
13+

docs/docs/modules.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ <h1>opentok<a class="headerlink" href="#opentok" title="Permalink to this headli
5454
<li class="toctree-l2"><a class="reference internal" href="opentok.html#module-opentok.exceptions">opentok.exceptions module</a></li>
5555
<li class="toctree-l2"><a class="reference internal" href="opentok.html#module-opentok.opentok">opentok.opentok module</a></li>
5656
<li class="toctree-l2"><a class="reference internal" href="opentok.html#module-opentok.session">opentok.session module</a></li>
57+
<li class="toctree-l2"><a class="reference internal" href="opentok.html#module-opentok.version">opentok.version module</a></li>
5758
<li class="toctree-l2"><a class="reference internal" href="opentok.html#module-opentok">Module contents</a></li>
5859
</ul>
5960
</li>

0 commit comments

Comments
 (0)