Esempio n. 1
0
        //Each stream key is only good for 24 hours.
        public static string RegenerateStreamKey(string streamId)
        {
            string wscapikey    = ConfigurationManager.AppSettings["wowzaApiKey"];
            string wscaccesskey = ConfigurationManager.AppSettings["wowzaAccessKey"];

            var client = new RestClient(WowzaApi + "live_streams");

            client.AddDefaultHeader("wsc-api-key", wscapikey);
            client.AddDefaultHeader("wsc-access-key", wscaccesskey);
            string id      = streamId;
            var    status  = 1;
            var    request = new RestRequest(id + "/regenerate_connection_code", Method.PUT);

            request.AddJsonBody(new { status = status });
            var response = client.Execute(request);

            if (response.StatusCode == System.Net.HttpStatusCode.OK)
            {
                WowzaResponse wr = JsonConvert.DeserializeObject <WowzaResponse>(response.Content);
                if (wr.live_stream != null)
                {
                    return(wr.live_stream.connection_code);
                }
            }
            return("No Connection Code");
        }
Esempio n. 2
0
        public static Models.Data.LiveStream CreateLiveStream(Service service)
        {
            string         wscapikey    = ConfigurationManager.AppSettings["wowzaApiKey"];
            string         wscaccesskey = ConfigurationManager.AppSettings["wowzaAccessKey"];
            string         name         = service.FirstName + " " + service.LastName + " " + service.FuneralHome.UserName + service.Id;
            LiveStreamPost ls           = new LiveStreamPost()
            {
                aspect_ratio_height = 720,
                aspect_ratio_width  = 1280,
                billing_mode        = "pay_as_you_go",
                broadcast_location  = "us_west_california",
                closed_caption_type = "none",
                encoder             = "wowza_gocoder",
                hosted_page         = false,
                name                     = name,
                player_countdown         = false,
                player_responsive        = true,
                player_type              = "wowza_player",
                player_width             = 0,
                recording                = true,
                target_delivery_protocol = "hls",
                transcoder_type          = "transcoded",
                use_stream_source        = false,
            };
            var client = new RestClient(WowzaApi + "live_streams");

            client.AddDefaultHeader("wsc-api-key", wscapikey);
            client.AddDefaultHeader("wsc-access-key", wscaccesskey);

            var       request = new RestRequest(Method.POST);
            WowzaPost root    = new WowzaPost()
            {
                live_stream = ls
            };

            request.RequestFormat = DataFormat.Json;
            request.AddBody(root);
            var           response = client.Execute(request);
            WowzaResponse wr       = JsonConvert.DeserializeObject <WowzaResponse>(response.Content);

            if (wr != null && wr.live_stream != null)
            {
                Models.Data.LiveStream liveStream = CreateAndStoreLiveStream(service, wr.live_stream.id, wr.live_stream.player_hls_playback_url, wr.live_stream.connection_code);
                liveStream.Started = false;
                return(liveStream);
            }
            return(null);
        }
Esempio n. 3
0
        public static WowzaResponse GetLiveStream(string WowzaLiveStreamId)
        {
            string wscapikey    = ConfigurationManager.AppSettings["wowzaApiKey"];
            string wscaccesskey = ConfigurationManager.AppSettings["wowzaAccessKey"];
            var    client       = new RestClient(WowzaApi + "live_streams/" + WowzaLiveStreamId);

            client.AddDefaultHeader("wsc-api-key", wscapikey);
            client.AddDefaultHeader("wsc-access-key", wscaccesskey);

            var request = new RestRequest(Method.GET);

            request.RequestFormat = DataFormat.Json;

            var           response = client.Execute(request);
            WowzaResponse wr       = JsonConvert.DeserializeObject <WowzaResponse>(response.Content);

            return(wr);
        }
Esempio n. 4
0
        private static string BuildAppOpenCode(WowzaResponse streamObject)
        {
            string publishHost             = streamObject.live_stream.source_connection_information.primary_server;
            string publishPort             = streamObject.live_stream.source_connection_information.host_port.ToString();
            string publishApplication      = streamObject.live_stream.source_connection_information.application;
            string publishStream           = streamObject.live_stream.source_connection_information.stream_name;
            string publishUser             = streamObject.live_stream.source_connection_information.username;
            string publishPassword         = streamObject.live_stream.source_connection_information.password;
            string publishAutoRestart      = "YES";
            string publishBroadCastType    = "2";
            string publishFPS              = "25";
            string publishKeyFrameInterval = "50";
            string publishFrameSizeIndex   = "7";
            string publishFilterType       = "0";
            string publishURL              = "https://player.cloud.wowza.com/";
            string publishBitrateIndex     = "1";
            // streamObject.live_stream.source_connection_information.
            string code = "gocoder://configure/?publishUseTCP=YES&publishHost=" + publishHost + "&publishPort=" + publishPort + "&publishApplication=" + publishApplication + "&publishStream=" + publishStream + "&publishUser="******"&publishPassword="******"&publishAutoRestart=" + publishAutoRestart + "&publishBroadcastType=" + publishBroadCastType + "&publishFPS=" + publishFPS + "&publishKeyFrameInterval=" + publishKeyFrameInterval + "&publishBitrateIndex=" + publishBitrateIndex + "&publishFrameSizeIndex=" + publishFrameSizeIndex + "&publishFilterType=" + publishFilterType + "&publishURL=" + publishURL;

            code = "gocoder://configure/?publishUseTCP=YES&publishHost=" + publishHost + "&publishPort=" + publishPort + "&publishApplication=" + publishApplication + "&publishStream=" + publishStream + "&publishUser="******"&publishPassword=" + publishPassword;
            return(code);
        }