private unsafe void EncodeFrame(SoftwareBitmap frame) { RTMPEncoder encoder = new RTMPEncoder(); encoder.Ffmpeg_init(400, 300, 128000, App.RTMPUrl); //encoder.Ffmpeg_encodeVideoFrame(data); }
/// <summary> /// Setup youtube channel. Needs to refine it all. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void LaunchPage_Loaded(object sender, RoutedEventArgs e) { //Move authorize to a common class user = await GoogleWebAuthorizationBroker.AuthorizeAsync( new Uri("ms-appx:///client_secret.json"), scope, "user", CancellationToken.None ); youtubeService = new YouTubeService(new BaseClientService.Initializer() { HttpClientInitializer = user, ApplicationName = "WatchMe" }); //Individual youtube section to be moved to helper classes SearchResource.ListRequest listRequest = youtubeService.Search.List("snippet"); listRequest.MaxResults = 10; listRequest.Q = "Microsoft"; SearchListResponse searchResponse = await listRequest.ExecuteAsync(); //YoutubePlayer.Source = new Uri("https://progressivemlx-a.akamaihd.net:443/asset-5f19445d-1500-80c4-d8fd-f1e5a5ddee3a/16914-237342-od1s011z.knj_H264_3400kbps_AAC_und_ch2_96kbps.mp4"); //YoutubePlayer.Source = new Uri("https://www.youtube.com/v/V_XUSOLVRzA"); //YoutubePlayer.Play(); //Create broadcast snippet LiveBroadcastSnippet livebcSnippet = new LiveBroadcastSnippet(); livebcSnippet.Title = "Hello Public Broadcast"; livebcSnippet.ScheduledStartTime = DateTime.Now; livebcSnippet.ScheduledEndTime = DateTime.Now.AddHours(2); //Set broadcast privacy LiveBroadcastStatus livebcStatus = new LiveBroadcastStatus(); livebcStatus.PrivacyStatus = "public"; //Create Live Broadcast request combining the above parts LiveBroadcast liveBCRequest = new LiveBroadcast(); liveBCRequest.Kind = "youtube#liveBroadcast"; liveBCRequest.Snippet = livebcSnippet; liveBCRequest.Status = livebcStatus; //Create the live broadcast in youtube LiveBroadcastsResource.InsertRequest liveBCInsertRequest = youtubeService.LiveBroadcasts.Insert(liveBCRequest, "snippet,status"); //Final Live Broadcast reponse LiveBroadcast liveBCResponse = await liveBCInsertRequest.ExecuteAsync(); //Create liveStream snippet LiveStreamSnippet liveStreamSnippet = new LiveStreamSnippet(); liveStreamSnippet.Title = "Live Video Public"; // Define the content distribution network settings for the video stream. // The settings specify the stream's format and ingestion type. CdnSettings cdnSettings = new CdnSettings(); cdnSettings.Format = "1080p"; cdnSettings.IngestionType = "rtmp"; //Create liveStream request LiveStream liveStreamRequest = new LiveStream(); liveStreamRequest.Kind = "youtube#liveStream"; liveStreamRequest.Snippet = liveStreamSnippet; liveStreamRequest.Cdn = cdnSettings; //Create the live stream in youtube LiveStreamsResource.InsertRequest liveStreamInsertRequest = youtubeService.LiveStreams.Insert(liveStreamRequest, "snippet,cdn"); //Final Live Stream reponse LiveStream liveStreamResponse = await liveStreamInsertRequest.ExecuteAsync(); // Construct and execute a request to bind the new broadcast and stream. LiveBroadcastsResource.BindRequest bindRequest = youtubeService.LiveBroadcasts.Bind(liveBCResponse.Id, "id,contentDetails"); bindRequest.StreamId = liveStreamResponse.Id; // The LiveBroadcast object bound to the LiveStream LiveBroadcast boundBroadcast = await bindRequest.ExecuteAsync(); App.RTMPUrl = liveStreamResponse.Cdn.IngestionInfo.IngestionAddress + "/" + liveStreamResponse.Cdn.IngestionInfo.StreamName; encoder = new RTMPEncoder(); if (encoder.Ffmpeg_init(400, 300, AUDIO_SAMPLE_RATE, App.RTMPUrl)) { Debug.WriteLine("encoder initialization successfull"); } else { Debug.WriteLine("encoder initialization failed"); } ChangeScenarioState(ScenarioState.Ready); }