Пример #1
0
        /**
         * Starts archiving an OpenTok session.
         *
         * <p>
         * Clients must be actively connected to the OpenTok session for you to successfully start
         * recording an archive.
         * <p>
         * You can only record one archive at a time for a given session. You can only record
         * archives of sessions that uses the OpenTok Media Router (sessions with the media mode set
         * to routed); you cannot archive sessions with the media mode set to relayed.
         * <p>
         * Note that you can have the session be automatically archived by setting the archiveMode
         * parameter of the OpenTok.CreateSession() method to ArchiveMode.ALWAYS.
         *
         * @param sessionId The session ID of the OpenTok session to archive.
         *
         * @param name The name of the archive. You can use this name to identify the archive. It is
         * a property of the Archive object, and it is a property of archive-related events in the
         * OpenTok client libraries.
         *
         * @param hasVideo Whether the archive will record video (true) or not (false). The default
         * value is true (video is recorded). If you set both <code>hasAudio</code> and
         * <code>hasVideo</code> to false, the call to the <code>StartArchive()</code> method
         * results in an error.
         *
         * @param hasAudio Whether the archive will record audio (true) or not (false). The default
         * value is true (audio is recorded). If you set both <code>hasAudio</code> and
         * <code>hasVideo</code> to false, the call to the <code>StartArchive()</code> method
         * results in an error.
         *
         * @param outputMode Whether all streams in the archive are recorded to a single file
         * (<code>OutputMode.COMPOSED</code>, the default) or to individual files
         * (<code>OutputMode.INDIVIDUAL</code>).
         *
         * @param resolution The resolution for the archive. The default for <code>OutputMode.COMPOSED</code>
         * is "640x480". You cannot specify the resolution for <code>OutputMode.INDIVIDUAL</code>.
         *
         * @return The Archive object. This object includes properties defining the archive,
         * including the archive ID.
         */
        public Archive StartArchive(string sessionId, string name = "", bool hasVideo = true, bool hasAudio = true, OutputMode outputMode = OutputMode.COMPOSED, string resolution = null)
        {
            if (String.IsNullOrEmpty(sessionId))
            {
                throw new OpenTokArgumentException("Session not valid");
            }
            string url     = string.Format("v2/project/{0}/archive", this.ApiKey);
            var    headers = new Dictionary <string, string> {
                { "Content-type", "application/json" }
            };
            var data = new Dictionary <string, object>()
            {
                { "sessionId", sessionId }, { "name", name }, { "hasVideo", hasVideo }, { "hasAudio", hasAudio }, { "outputMode", outputMode.ToString().ToLowerInvariant() }
            };

            if (!String.IsNullOrEmpty(resolution) && outputMode.Equals(OutputMode.INDIVIDUAL))
            {
                throw new OpenTokArgumentException("Resolution can't be specified for Individual Archives");
            }
            else if (!String.IsNullOrEmpty(resolution) && outputMode.Equals(OutputMode.COMPOSED))
            {
                data.Add("resolution", resolution);
            }
            string response = Client.Post(url, headers, data);

            return(OpenTokUtils.GenerateArchive(response, ApiKey, ApiSecret, OpenTokServer));
        }
Пример #2
0
        /**
         * Starts archiving an OpenTok session.
         *
         * <p>
         * Clients must be actively connected to the OpenTok session for you to successfully start
         * recording an archive.
         * <p>
         * You can only record one archive at a time for a given session. You can only record
         * archives of sessions that uses the OpenTok Media Router (sessions with the media mode set
         * to routed); you cannot archive sessions with the media mode set to relayed.
         * <p>
         * Note that you can have the session be automatically archived by setting the archiveMode
         * parameter of the OpenTok.CreateSession() method to ArchiveMode.ALWAYS.
         *
         * @param sessionId The session ID of the OpenTok session to archive.
         *
         * @param name The name of the archive. You can use this name to identify the archive. It is
         * a property of the Archive object, and it is a property of archive-related events in the
         * OpenTok client libraries.
         *
         * @param hasVideo Whether the archive will record video (true) or not (false). The default
         * value is true (video is recorded). If you set both <code>hasAudio</code> and
         * <code>hasVideo</code> to false, the call to the <code>StartArchive()</code> method
         * results in an error.
         *
         * @param hasAudio Whether the archive will record audio (true) or not (false). The default
         * value is true (audio is recorded). If you set both <code>hasAudio</code> and
         * <code>hasVideo</code> to false, the call to the <code>StartArchive()</code> method
         * results in an error.
         *
         * @param outputMode Whether all streams in the archive are recorded to a single file
         * (<code>OutputMode.COMPOSED</code>, the default) or to individual files
         * (<code>OutputMode.INDIVIDUAL</code>).
         *
         * @return The Archive object. This object includes properties defining the archive,
         * including the archive ID.
         */
        public Archive StartArchive(string sessionId, string name = "", bool hasVideo = true, bool hasAudio = true, OutputMode outputMode = OutputMode.COMPOSED)
        {
            if (String.IsNullOrEmpty(sessionId))
            {
                throw new OpenTokArgumentException("Session not valid");
            }
            string url     = string.Format("v2/partner/{0}/archive", this.ApiKey);
            var    headers = new Dictionary <string, string> {
                { "Content-type", "application/json" }
            };
            var data = new Dictionary <string, object>()
            {
                { "sessionId", sessionId }, { "name", name }, { "hasVideo", hasVideo }, { "hasAudio", hasAudio }, { "outputMode", outputMode.ToString().ToLower() }
            };
            string response = Client.Post(url, headers, data);

            return(OpenTokUtils.GenerateArchive(response, ApiKey, ApiSecret, OpenTokServer));
        }
Пример #3
0
        /**
         * Starts archiving an OpenTok 2.0 session.
         *
         * <p>
         * Clients must be actively connected to the OpenTok session for you to successfully start
         * recording an archive.
         * <p>
         * You can only record one archive at a time for a given session. You can only record
         * archives of sessions that uses the OpenTok Media Router; you cannot archive peer-to-peer
         * sessions.
         *
         * @param sessionId The session ID of the OpenTok session to archive.
         *
         * @param name The name of the archive. You can use this name to identify the archive. It is
         * a property of the Archive object, and it is a property of archive-related events in the
         * OpenTok client libraries.
         *
         * @return The Archive object. This object includes properties defining the archive,
         * including the archive ID.
         */
        public Archive StartArchive(string sessionId, string name = "")
        {
            if (String.IsNullOrEmpty(sessionId))
            {
                throw new OpenTokArgumentException("Session not valid");
            }
            string url     = string.Format("v2/partner/{0}/archive", this.ApiKey);
            var    headers = new Dictionary <string, string> {
                { "Content-type", "application/json" }
            };
            var data = new Dictionary <string, object>()
            {
                { "sessionId", sessionId }, { "name", name }
            };
            string response = Client.Post(url, headers, data);

            return(OpenTokUtils.GenerateArchive(response, ApiKey, ApiSecret, OpenTokServer));
        }