예제 #1
0
        public static async Task <VideoFileInfo> TranscodeVideo(
            [ActivityTrigger] VideoFileInfo inputVideo,
            TraceWriter log)
        {
            log.Info($"Transcoding {inputVideo}");

            await Task.Delay(1000);

            var transcodedLocation = $"{Path.GetFileNameWithoutExtension(inputVideo.Location)}-" + $"{ inputVideo.BitRate}kbps.mp4";

            return(new VideoFileInfo
            {
                Location = transcodedLocation,
                BitRate = inputVideo.BitRate,
            });
        }
        public static async Task <VideoFileInfo> TransocdeVideo(
            [ActivityTrigger] VideoFileInfo inputVideo,
            ILogger log)
        {
            log.LogInformation($"Transcoding {inputVideo.Location} to {inputVideo.BitRate}");
            // simulate doing the activity
            await Task.Delay(5000);

            string transcodedLocation =
                $"{Path.GetFileNameWithoutExtension(inputVideo.Location)}-{inputVideo.BitRate}kbps.mp4";

            return(new VideoFileInfo
            {
                Location = transcodedLocation,
                BitRate = inputVideo.BitRate
            });
        }
        public static async Task <VideoFileInfo[]> TranscodeVideo(
            [OrchestrationTrigger] DurableOrchestrationContext ctx, TraceWriter log)
        {
            var videoLocation = ctx.GetInput <string>();
            var bitRates      = await ctx.CallActivityAsync <int[]>("A_GetTranscodeBitrates", null);

            var transcodeTasks = new List <Task <VideoFileInfo> >();

            foreach (var bitRate in bitRates)
            {
                var info = new VideoFileInfo()
                {
                    Location = videoLocation, BitRate = bitRate
                };
                var task = ctx.CallActivityAsync <VideoFileInfo>("A_TranscodeVideo", info);
                transcodeTasks.Add(task);
            }

            var transcodeResults = await Task.WhenAll(transcodeTasks);

            return(transcodeResults);
        }