Example #1
0
 public bool VideoParamCompare(VideoAdjusterParam videoAdjusterParam, VideoParam videoParam, string newContainer, IVideoSize videoSize)
 {
     return videoAdjusterParam.VideoCodec == videoParam.VideoCodec
            && ((newContainer == MetadataConstant.Mp4Container && videoAdjusterParam.VideoProfile == videoParam.VideoProfile) || (MetadataConstant.Mp4Container != newContainer))
            && videoAdjusterParam.VideoBitrate == videoParam.VideoBitrate
            && videoSize.Width == videoParam.VideoWidth
            && videoSize.Height == videoParam.VideoHeight
            && videoAdjusterParam.FrameRate == videoParam.FrameRate
            && videoAdjusterParam.KeyFrameRate == videoParam.KeyFrameRate;
 }
Example #2
0
        public void Initialize()
        {
            const string mediaContainer = "mediaContainer";
            const string videoCodec = "videoCodec";
            const string videoProfile = "videoProfile";
            const int videoBitrate = 10000;
            const int width = 150;
            const int height = 100;
            const double frameRate = 25;
            const int keyFrameRate = 10;

            const string audioCodec = "audioCodec";
            const int audioBitrate = 500;

            _comparator = new Comparator();

            _videoSize = new VideoSize(width, height);

            _videoAdjusterParam = new VideoAdjusterParam()
                              {
                                  MediaContainer = mediaContainer,
                                  VideoCodec = videoCodec,
                                  VideoProfile = videoProfile,
                                  VideoBitrate = videoBitrate,
                                  FrameRate = frameRate,
                                  KeyFrameRate = keyFrameRate
                              };

            _videoParam = new VideoParam()
                              {
                                  MediaContainer = mediaContainer,
                                  VideoCodec = videoCodec,
                                  VideoProfile = videoProfile,
                                  VideoBitrate = videoBitrate,
                                  VideoWidth = width,
                                  VideoHeight = height,
                                  FrameRate = frameRate,
                                  KeyFrameRate = keyFrameRate
                              };
            
            _audioAdjusterParam = new AudioAdjusterParam()
                               {
                                   AudioCodec = audioCodec,
                                   AudioBitrate = audioBitrate
                               };

            _audioParam = new AudioParam()
                               {
                                   AudioCodec = audioCodec,
                                   AudioBitrate = audioBitrate
                               };
        }
 private DomainProcessedVideo CreateProcessedVideo(VideoParam videoParam, AudioParam audioParam, bool isVideoCopy, bool isAudioCopy, string contentType)
 {
     return new DomainProcessedVideo
     {
         VideoParam = videoParam,
         AudioParam = audioParam,
         IsVideoCopy = isVideoCopy,
         IsAudioCopy = isAudioCopy,
         OutputFormat = String.Format("{0}x{1}", videoParam.MediaContainer, videoParam.VideoWidth),
         ContentType = contentType,
         Created = DateTime.UtcNow,
         Modified = DateTime.UtcNow,
         Started = DateTime.UtcNow,
         Completed = DateTime.UtcNow
     };
 }
        public void BuildProcessedVideoTest()
        {
            //Arrange
            const string newContainer = "newContainer";
            const string contentType = "contentType";
            const bool isVideoParamEquals = true;
            const bool isAudioParamEquals = false;
            const int videoWidth = 2134;
           
            var videoAdjusterParam = new VideoAdjusterParam();
            var audioAdjusterParam = new AudioAdjusterParam();

            var videoParam = new VideoParam() { VideoWidth = videoWidth, MediaContainer = newContainer };
            var audioParam = new AudioParam();
            var outputFormat = string.Format("{0}x{1}", videoParam.MediaContainer, videoParam.VideoWidth);
            
            var videoSize = new Mock<IVideoSize>();
            var videoParamAdjuster = new Mock<IVideoAdjuster>();
            var audioParamAdjuster = new Mock<IAudioAdjuster>();
            var comparator = new Mock<IComparator>();

            videoParamAdjuster.Setup(m => m.AdjustVideoParam(videoAdjusterParam, newContainer, videoSize.Object)).Returns(videoParam);
            audioParamAdjuster.Setup(m => m.AdjustAudioParam(audioAdjusterParam, newContainer, videoSize.Object)).Returns(audioParam);
            comparator.Setup(m => m.VideoParamCompare(videoAdjusterParam, videoParam, newContainer, videoSize.Object)).Returns(isVideoParamEquals);
            comparator.Setup(m => m.AudioParamCompare(audioAdjusterParam, audioParam)).Returns(isAudioParamEquals);

            var builder = new ProcessedVideoBuilder(videoParamAdjuster.Object, audioParamAdjuster.Object, comparator.Object);

            //Act
            var processedVideo = builder.BuildProcessedVideo(videoAdjusterParam, audioAdjusterParam, newContainer, videoSize.Object, contentType);

            //Assert
            Assert.AreEqual(videoParam, processedVideo.VideoParam);
            Assert.AreEqual(audioParam, processedVideo.AudioParam);
            Assert.AreEqual(isVideoParamEquals, processedVideo.IsVideoCopy);
            Assert.AreEqual(isAudioParamEquals, processedVideo.IsAudioCopy);
            Assert.AreEqual(outputFormat, processedVideo.OutputFormat);
            Assert.AreEqual(contentType, processedVideo.ContentType);
        }