/// <summary> /// Initializes the ModuleClient and sets up the callback to receive /// messages containing temperature information /// </summary> static async Task Init() { MqttTransportSettings mqttSetting = new MqttTransportSettings(TransportType.Mqtt_Tcp_Only); ITransportSettings[] settings = { mqttSetting }; // Open a connection to the Edge runtime ModuleClient ioTHubModuleClient = await ModuleClient.CreateFromEnvironmentAsync(settings); await ioTHubModuleClient.OpenAsync(); Console.WriteLine("IoT Hub module client initialized."); var connectionString = Environment.GetEnvironmentVariable("STORAGE_CONNECTION_STRING"); var containerName = Environment.GetEnvironmentVariable("RESULT_CONTAINER_NAME"); var storageAccount = CloudStorageAccount.Parse(connectionString); var cloudBlobClient = storageAccount.CreateCloudBlobClient(); cloudBlobContainer = cloudBlobClient.GetContainerReference(containerName); await cloudBlobContainer.CreateIfNotExistsAsync(); http = new HttpRouter(new string[] { "http://+:80/" }); http.Register("/caption", SetCaption); http.Register("/video/start", StartRecording); http.Register("/video/end", EndRecording); http.Register("/photo", TakePhoto); http.Start(); await Task.CompletedTask; }
/// <summary> /// Initializes the ModuleClient and sets up the callback to receive /// messages containing temperature information /// </summary> static async Task Init() { MqttTransportSettings mqttSetting = new MqttTransportSettings(TransportType.Mqtt_Tcp_Only); ITransportSettings[] settings = { mqttSetting }; // Open a connection to the Edge runtime ModuleClient ioTHubModuleClient = await ModuleClient.CreateFromEnvironmentAsync(settings); await ioTHubModuleClient.OpenAsync(); WriteLog("IoT Hub module client initialized."); var connectionString = Environment.GetEnvironmentVariable("STORAGE_CONNECTION_STRING"); var containerName = Environment.GetEnvironmentVariable("RESULT_CONTAINER_NAME"); var storageAccount = CloudStorageAccount.Parse(connectionString); var cloudBlobClient = storageAccount.CreateCloudBlobClient(); cloudBlobContainer = cloudBlobClient.GetContainerReference(containerName); await cloudBlobContainer.CreateIfNotExistsAsync(); // XXX 環境変数に videoInputStream = new VideoInputStream(0); videoInputStream.Start(); var rtmpUri = Environment.GetEnvironmentVariable("RTMP_URI"); // XXX Size videoLiveStream = new FfmpegRtmpVideoOutputStream(rtmpUri, fps, new Size(320, 240)); videoLiveStream.Start(); caption = new CaptionRequest { Caption = "" }; captionFont = new System.Drawing.Font("noto", 15f); smallFont = new System.Drawing.Font("noto", 10f); frameTimer = new System.Timers.Timer(1.0 / fps); frameTimer.Elapsed += UpdateFrame; frameTimer.Start(); http = new HttpRouter(new string[] { "http://+:80/" }); http.Register("/caption", SetCaption); http.Register("/video/start", StartRecording); http.Register("/video/end", EndRecording); http.Register("/photo", TakePhoto); http.Register("/photo_with_caption", TakePhotoWithCaption); http.Start(); await Task.CompletedTask; }