public void Initialize()
 {
     _ecodeData = new VideoEncodeData()
     {
         AudioParam = new AudioParam()
         {
             AudioCodec = AudioCodec,
             AudioBitrate = AudioBitrate
         },
         VideoParam = new VideoParam()
         {
             MediaContainer = MediaContatiner,
             VideoCodec = VideoCodec,
             VideoProfile = VideoProfile,
             VideoBitrate = VideoBitrate,
             FrameRate = FrameRate,
             KeyFrameRate = KeyFrame,
             VideoWidth = Width,
             VideoHeight = Height,
             VideoRotation = VideoRotation
         },
         IsAudioCopy = IsAudioCopy,
         IsVideoCopy = IsVideoCopy
     };
 }
 public VideoEncodeStringBuilder(VideoEncodeData encodeData, IVideoEncodeStringFactory videoEncodeStringFactory, ITempFileManager tempFileManager)
     : base(encodeData)
 {
     _encodeData = encodeData;
     _videoEncodeStringFactory = videoEncodeStringFactory;
     _tempFileManager = tempFileManager;
 }
Ejemplo n.º 3
0
        public void CreateEncodeStringFactoryTest()
        {
            //Arrange
            var encodeData = new VideoEncodeData();
            var videoCreator = new VideoEncodeCreator(encodeData);

            //Act
            var encodeStringFactory = videoCreator.CreateEncodeStringFactory();

            //Assert
            Assert.AreEqual(typeof(VideoEncodeStringFactory), encodeStringFactory.GetType());
        }
Ejemplo n.º 4
0
        public void CreateFfmpegParserTest()
        {
            //Arrange
            var encodeData = new VideoEncodeData();
            var videoCreator = new VideoEncodeCreator(encodeData);

            //Act
            var videoFfmpegString = videoCreator.CreateFfmpegParser();

            //Assert
            Assert.AreEqual(typeof (VideoFfmpegParser), videoFfmpegString.GetType());
        }
        public void CreateVideoEncodeCreatorTest()
        {
            //Arrange
            var encodeData = new VideoEncodeData();
            var creatorFactory = new EncodeCreatorFactory();

            //Act
            var creator = creatorFactory.Create(encodeData);

            //Assert
            Assert.IsInstanceOfType(creator, typeof(VideoEncodeCreator));
        }
Ejemplo n.º 6
0
        public void CreateEncodeStringBuilderTest()
        {
            //Arrange
            var encodeData = new VideoEncodeData();
            var videoCreator = new VideoEncodeCreator(encodeData);
            var encodeStringFactory = new Mock<IVideoEncodeStringFactory>();
            var tempFileManager = new Mock<ITempFileManager>();

            //Act
            var encodeStringBuilder = videoCreator.CreateEncodeStringBuilder(tempFileManager.Object, encodeStringFactory.Object);

            //Assert
            Assert.AreEqual(typeof(VideoEncodeStringBuilder), encodeStringBuilder.GetType());
        }
Ejemplo n.º 7
0
        public void VideoDataDeserializeTest()
        {
            //Arrange
            const TypeOfTask typeOfType = TypeOfTask.Video;

            var deserializer = new Mock<IDeserializer>();
            var response = new Mock<IRestResponse>();
            var encodeDeserializer = new EncodeDeserializer(deserializer.Object);

            var data = new VideoEncodeData();

            deserializer.Setup(m => m.Deserialize<VideoEncodeData>(response.Object)).Returns(data);

            //Act 
            var encodeData = encodeDeserializer.EncodeDataDeserialize(response.Object, typeOfType);

            //Assert
            Assert.AreEqual(data, encodeData);
        }
Ejemplo n.º 8
0
 public VideoEncodeCreator(VideoEncodeData data)
 {
     _data = data;
 }
Ejemplo n.º 9
0
        public void EncodeMp4TaskTest()
        {
            //Arrange
            var taskData = new EncodeTaskData()
                               {
                                   TaskId = TaskId
                               };
            var encodeData = new VideoEncodeData()
                                 {
                                     FileId = ConfigurationManager.AppSettings.Get("TestVideo"),
                                     ContentType = "video/mp4",
                                     AudioParam = new AudioParam()
                                                      {
                                                          AudioCodec = MetadataConstant.AacCodec,
                                                          AudioBitrate = 64000
                                                      },
                                     VideoParam = new VideoParam()
                                                      {
                                                          VideoWidth = 480,
                                                          VideoHeight = 360,
                                                          
                                                          VideoCodec = MetadataConstant.AvcCodec,
                                                          VideoBitrate = 500000,
                                                          VideoProfile = MetadataConstant.AvcMainProfile,
                                                          MediaContainer = MetadataConstant.Mp4Container,
                                                          FrameRate = 25,
                                                          KeyFrameRate = 10
                                                      }
                                 };

            var serializer = new JsonSerializer();
            var jsonEncodeData = serializer.Serialize(encodeData);
            var jsonTaskData = serializer.Serialize(taskData);
            var getTaskHeaders = VideoGetTaskResponseHeaders(Resource);

            ResponseSetup(jsonTaskData, jsonEncodeData, getTaskHeaders);
            RestClientSetup(Resource);
            
            //Act
            var task = _manager.Start();
            task.Wait();

            Trace.WriteLine(_deleteRequest.Parameters.FirstOrDefault(p => p.Name == EncoderStatusParameters.Result).Value);

            //Assert
            Assert.IsTrue(_deleteRequest.Parameters.Any(p => p.Name == EncoderStatusParameters.Result && (EncoderState)p.Value == EncoderState.Completed));
        }
Ejemplo n.º 10
0
        public void FfmpegHangingTest()
        {
            //Arrange
            var taskData = new EncodeTaskData()
            {
                TaskId = TaskId
            };
            var encodeData = new VideoEncodeData()
                                 {
                                     FileId = ConfigurationManager.AppSettings.Get("HangingVideo"),
                                     ContentType = "video/webm",
                                     AudioParam = new AudioParam()
                                                      {
                                                          AudioCodec = MetadataConstant.VorbisCodec,
                                                          AudioBitrate = 128000,
                                                      },
                                     VideoParam = new VideoParam()
                                                      {
                                                          VideoWidth = 480,
                                                          VideoHeight = 360,

                                                          VideoCodec = MetadataConstant.Vp8Codec,
                                                          VideoBitrate = 500000,
                                                          MediaContainer = MetadataConstant.WebmContainer,
                                                          FrameRate = 25,
                                                          KeyFrameRate = 10
                                                      }
                                 };

            var serializer = new JsonSerializer();
            var jsonEncodeData = serializer.Serialize(encodeData);
            var jsonTaskData = serializer.Serialize(taskData);
            var getTaskHeaders = VideoGetTaskResponseHeaders(Resource);

            ResponseSetup(jsonTaskData, jsonEncodeData, getTaskHeaders);
            RestClientSetup(Resource);

            //Act
            var task = _manager.Start();
            task.Wait();

            Trace.WriteLine(_deleteRequest.Parameters.FirstOrDefault(p => p.Name == EncoderStatusParameters.Result).Value);

            //Assert
            //Assert.IsTrue(_setStatusRequest.Parameters.Any(p=>p.Name==ProcessStatusParameters.State && (ProcessState)p.Value==ProcessState.Hanging));
            Assert.IsTrue(_deleteRequest.Parameters.Any(p => p.Name == EncoderStatusParameters.Result && (EncoderState)p.Value == EncoderState.Cancelled));
        }
Ejemplo n.º 11
0
        public void FfmpegErrorTest()
        {
            //Arrange
            var taskData = new EncodeTaskData()
            {
                TaskId = TaskId
            };
            var errorEncodeData = new VideoEncodeData()
                {
                    FileId = ConfigurationManager.AppSettings.Get("TestVideo"),
                    VideoParam = new VideoParam()
                        {
                            MediaContainer = MetadataConstant.Mp4Container
                        },
                    AudioParam = new AudioParam()
                        {
                            AudioCodec = MetadataConstant.AacCodec
                        }
                };

            var serializer = new JsonSerializer();
            var jsonEncodeData = serializer.Serialize(errorEncodeData);
            var jsonTaskData = serializer.Serialize(taskData);
            var getTaskHeaders = VideoGetTaskResponseHeaders(Resource);

            ResponseSetup(jsonTaskData, jsonEncodeData, getTaskHeaders);
            RestClientSetup(Resource);

            _restClient.Setup(m => m.Execute(_deleteRequest)).Callback(() => _token.Cancel());

            //Act
            var task = _manager.Start();
            task.Wait();

            Trace.WriteLine(_deleteRequest.Parameters.FirstOrDefault(p => p.Name == EncoderStatusParameters.Result).Value);

            //Assert
            Assert.IsTrue(_deleteRequest.Parameters.Any(p => p.Name == EncoderStatusParameters.Result && (EncoderState)p.Value == EncoderState.Failed));
        }