public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            ReadPresetResponse response = new ReadPresetResponse();

            context.Read();

            UnmarshallResult(context, response);
            return(response);
        }
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            ReadPresetResponse response = new ReadPresetResponse();

            context.Read();

            response.ReadPresetResult = ReadPresetResultUnmarshaller.GetInstance().Unmarshall(context);

            return(response);
        }
Ejemplo n.º 3
0
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            ReadPresetResponse response = new ReadPresetResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("Preset", targetDepth))
                {
                    response.Preset = PresetUnmarshaller.GetInstance().Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }
        private static void UnmarshallResult(JsonUnmarshallerContext context, ReadPresetResponse response)
        {
            int originalDepth = context.CurrentDepth;
            int targetDepth   = originalDepth + 1;

            while (context.Read())
            {
                if (context.TestExpression("Preset", targetDepth))
                {
                    context.Read();
                    response.Preset = PresetUnmarshaller.GetInstance().Unmarshall(context);
                    continue;
                }

                if (context.CurrentDepth <= originalDepth)
                {
                    return;
                }
            }

            return;
        }
Ejemplo n.º 5
0
        public async Task PutObject(SNSEvent snsEvent, ILambdaContext context)
        {
            this._Context = context;

            this._Context.LogInfo($"Received SNS event:\n{JsonConvert.SerializeObject(snsEvent)}");

            ReadPresetResponse Preset = await this._ETClient.ReadPresetAsync(new ReadPresetRequest()
            {
                Id = Environment.GetEnvironmentVariable("PresetId")
            });

            if (Preset != null && (int)Preset.HttpStatusCode >= 200 && (int)Preset.HttpStatusCode <= 299)
            {
                foreach (SNSRecord Record in snsEvent.Records)
                {
                    string Message = Record.Sns.Message;
                    this._Context.LogInfo($"Message:\n{Message}");
                    SNSS3RecordSet RecordSet = JsonConvert.DeserializeObject <SNSS3RecordSet>(Message);

                    foreach (SNSS3Record S3Record in RecordSet.Records)
                    {
                        string Key = S3Record.S3.Object.Key;

                        DateTime Now      = DateTime.Now;
                        string   Prefix   = $"{Now.Year.ToString()}/{Now.Month.ToString("00")}";
                        string   FileName = Path.GetFileNameWithoutExtension(Key);

                        this._Context.LogInfo($"Submitting job for {Key}.");

                        CreateJobRequest Request = new CreateJobRequest()
                        {
                            PipelineId = Environment.GetEnvironmentVariable("Pipeline"),
                            Input      = new JobInput()
                            {
                                AspectRatio = "auto",
                                Key         = Key,
                                Container   = "auto",
                                FrameRate   = "auto",
                                Interlaced  = "auto",
                                Resolution  = "auto"
                            },
                            Output = new CreateJobOutput()
                            {
                                PresetId         = Preset.Preset.Id,
                                Rotate           = "0",
                                ThumbnailPattern = $"{Prefix}/{FileName}_{{count}}",
                                Key = $"{Prefix}/{FileName}.{Preset.Preset.Container}"
                            }
                        };

                        try
                        {
                            CreateJobResponse Response = await this._ETClient.CreateJobAsync(Request);

                            if ((int)Response.HttpStatusCode >= 200 && (int)Response.HttpStatusCode <= 299)
                            {
                                this._Context.LogInfo($"Successfully submitted job for {Response.Job.Input.Key} with id {Response.Job.Id} and arn {Response.Job.Arn}.");
                            }
                            else
                            {
                                this._Context.LogError($"Failed to successfully submit job for {Response.Job.Input.Key} with status code: {(int)Response.HttpStatusCode}");
                            }
                        }
                        catch (Exception e)
                        {
                            this._Context.LogError($"Failed to transcode {Key}.", e);
                        }
                    }
                }
            }
            else
            {
                this._Context.LogError($"Failed to retrieve information about preset {Environment.GetEnvironmentVariable("PresetId")}.");
            }
        }