1717
1818from .version import __version__
1919from .session import Session
20- from .archives import Archive , ArchiveList
20+ from .archives import Archive , ArchiveList , OutputModes
2121from .exceptions import OpenTokException , RequestError , AuthError , NotFoundError , ArchiveError
2222
2323class Roles (Enum ):
@@ -264,7 +264,7 @@ def archive_url(self, archive_id=None):
264264 url = url + '/' + archive_id
265265 return url
266266
267- def start_archive (self , session_id , hasAudio = True , hasVideo = True , name = None ):
267+ def start_archive (self , session_id , has_audio = True , has_video = True , name = None , output_mode = OutputModes . composed ):
268268 """
269269 Starts archiving an OpenTok 2.0 session.
270270
@@ -285,14 +285,22 @@ def start_archive(self, session_id, hasAudio=True, hasVideo=True, name=None):
285285 an error.
286286 :param Boolean hasVideo: if set to True, a video track will be inserted to the archive.
287287 hasVideo is an optional parameter that is set to True by default.
288+ :param OutputModes outputMode: if set to composed, a single MP4 file composed of all streams
289+ will be generated. If you set it to individual it will create a ZIP container with multiple
290+ individual WEBM files and a JSON metadata file for video synchronization.
291+ outputMode is an optional parameter that is set to composed by default.
288292
289293 :rtype: The Archive object, which includes properties defining the archive,
290294 including the archive ID.
291295 """
296+ if not isinstance (output_mode , OutputModes ):
297+ raise OpenTokException (u ('Cannot start archive, {0} is not a valid output mode' ).format (output_mode ))
298+
292299 payload = {'name' : name ,
293300 'sessionId' : session_id ,
294- 'hasAudio' : hasAudio ,
295- 'hasVideo' : hasVideo
301+ 'hasAudio' : has_audio ,
302+ 'hasVideo' : has_video ,
303+ 'outputMode' : output_mode .value
296304 }
297305
298306 response = requests .post (self .archive_url (), data = json .dumps (payload ), headers = self .archive_headers ())
0 commit comments