Пример #1
0
        public static FunctionResult UpdateSettings(VideoPlayerSettings settings, UserInfo userInfo, string database, string table, string connectionString)
        {
            #region Preparation
            SystemConfiguration systemConfiguration = HelperClass.SystemConfigurationLoader();
            FunctionResult      result = new FunctionResult();
            #endregion Preparation

            #region SQL statement
            string SQLCommand = string.Empty;
            SQLCommand  = "USE " + database + ";";
            SQLCommand += "UPDATE " + table + " SET ";
            SQLCommand += "VideoHeight=" + (int)settings.resolution + ", ";
            SQLCommand += "FrameRate=" + (int)settings.frameRate + ", ";
            SQLCommand += "BufferMode=" + (int)settings.bufferMode + ", ";
            SQLCommand += "PreloadFrames=" + (int)settings.preloadFrames + " WHERE ";
            SQLCommand += "UserID=" + userInfo.UserID + ";";
            #endregion SQL statement

            if (!Peralatan.UbahDataDatabase(SQLCommand, systemConfiguration.DatabaseProcessingConfiguration.DatabaseConectionString))
            {
                result.functionResult = Result.Fail;
                result.functionErrroInformation.errorMessage = Peralatan.PesanKesalahan;
            }
            else
            {
                result.functionResult = Result.Success;
            }
            return(result);
        }
Пример #2
0
        VideoPlayerSettings LoadDefault()
        {
            VideoPlayerSettings settings = new VideoPlayerSettings();

            settings.resolution    = Resolution.SD_480p;
            settings.frameRate     = FrameRate._24fps;
            settings.preloadFrames = PreloadFrames.EnablePreload;
            settings.bufferMode    = BufferMode.SingleBuffer;
            return(settings);
        }
Пример #3
0
        public static bool WriteLog(string sessionID, VideoPlayerSettings userSettings, string connectionString)
        {
            #region Preparation
            // SettingsInformation
            string ID             = string.Empty;
            string userSettingsID = string.Empty;


            string SQLCommand = string.Empty;

            #endregion Preparation

            return(Peralatan.TambahKeDatabase(SQLCommand, connectionString));
        }
Пример #4
0
        public static bool CreateNewSettings(string database, string table, UserInfo userInfo, string connectionString)
        {
            VideoPlayerSettings playerSettings = new VideoPlayerSettings();

            playerSettings.bufferMode    = BufferMode.SingleBuffer;
            playerSettings.frameRate     = FrameRate._24fps;
            playerSettings.resolution    = Resolution.SD_480p;
            playerSettings.preloadFrames = PreloadFrames.EnablePreload;

            string userID = userInfo.UserID.ToString();

            string SQLCommand = string.Empty;

            SQLCommand += "USE " + database + ";";
            SQLCommand += "INSERT INTO " + table + " (UserID, VideoWidth, VideoHeight, FrameRate, BufferMode, PreloadFrames) VALUES (";
            SQLCommand += userID + ", 0, " + (int)playerSettings.resolution + ", " + (float)playerSettings.frameRate + ", " + (int)playerSettings.bufferMode + ", " + (int)playerSettings.preloadFrames + ");";

            return(Peralatan.TambahKeDatabase(SQLCommand, connectionString));
        }
Пример #5
0
        public ProcessedVideo ProcessVideo(VideoProcessingInformation videoInformation, SystemConfiguration systemConfiguration, UserInfo userInfo, bool isFileUpload = false)
        {
            if (!isFileUpload)
            {
                // Check if input is an http url
                #region Preparation
                ProcessedVideo   videoInfo = new ProcessedVideo();
                ProcessStartInfo startInfo = new ProcessStartInfo(systemConfiguration.VideoProcessorLocation);
                FFProbe          fFProbe   = new FFProbe();
                bool             isHttp    = Validator.IsHttp(videoInformation.VideoLocations.VideoLocation);
                string           ID        = userInfo.SessionID;

                #region Working directories
                string temporaryWorkingDirectory      = string.Empty;
                string temporaryVideoDirectory        = systemConfiguration.TemporaryVideoSaveLocation;
                string processedVideoSaveLocation     = systemConfiguration.ProcessedVideoSaveLocation;
                string networkProcessedVideoDirectory = string.Empty;
                #endregion Working directories

                #endregion Preparation

                #region Working directory setup

                #region Temporary directory
                // Setting up working directory
                if (temporaryVideoDirectory.EndsWith("\\"))
                {
                    temporaryWorkingDirectory = temporaryVideoDirectory + ID;
                }
                else
                {
                    temporaryWorkingDirectory = temporaryVideoDirectory + "\\" + ID;
                }

                // Check for directory
                if (!Directory.Exists(temporaryWorkingDirectory))
                {
                    Directory.CreateDirectory(temporaryWorkingDirectory);
                }
                #endregion Temporary directory

                #region Processed directory
                string processedVideoDirectory = string.Empty;
                if (videoInformation.VideoLocations.videoSaveLocation == "default")
                {
                    throw new NotImplementedException("Custom path is not yet supported.");
                    if (videoInformation.VideoLocations.videoSaveLocation.EndsWith("\\"))
                    {
                        processedVideoDirectory = videoInformation.VideoLocations.videoSaveLocation + ID;
                    }
                    else
                    {
                        processedVideoDirectory = videoInformation.VideoLocations.videoSaveLocation + "\\" + ID;
                    }
                    //Check for directory
                    if (!Directory.Exists(processedVideoDirectory))
                    {
                        Directory.CreateDirectory(processedVideoDirectory);
                    }
                }
                else
                {
                    if (processedVideoSaveLocation.EndsWith("\\"))
                    {
                        processedVideoDirectory = processedVideoSaveLocation + ID;
                    }
                    else
                    {
                        processedVideoDirectory = processedVideoSaveLocation + "\\" + ID;
                    }

                    //Check for directory
                    if (!Directory.Exists(processedVideoDirectory))
                    {
                        Directory.CreateDirectory(processedVideoDirectory);
                    }
                }

                #endregion Processed directory

                #region Network processed directory

                if (!Directory.Exists(processedVideoDirectory))
                {
                    throw new Exception("Cannot create network folder if local folder isn't available.");
                }
                if (videoInformation.VideoLocations.videoNetworkSaveLocation.EndsWith("/"))
                {
                    networkProcessedVideoDirectory = videoInformation.VideoLocations.videoNetworkSaveLocation + ID + "/";
                }
                else
                {
                    networkProcessedVideoDirectory = videoInformation.VideoLocations.videoNetworkSaveLocation + "/" + ID + "/";
                }
                #endregion Network processed directory

                #endregion Working directory setup

                // Check video configurations
                #region  Video settings
                int videoHeight;
                if (videoInformation.VideoSetting.processedVideoResolution == Resolution.Other)
                {
                    videoHeight = videoInformation.VideoSetting.height;
                }
                else if (videoInformation.VideoSetting.processedVideoResolution == Resolution.Original)
                {
                    videoHeight = -1;
                }
                else
                {
                    videoHeight = (int)videoInformation.VideoSetting.processedVideoResolution;
                }
                //int videoWidth = configurations.VideoWidth;
                //bool scale = configurations.scale;

                #endregion Video settings

                if (isHttp)
                {
                    #region File name processing

                    #region Get filename from URL
                    string[] URLParts     = videoInformation.VideoLocations.VideoLocation.Split('?');
                    string   resultURL    = string.Empty;
                    string   tempFileName = string.Empty;
                    string   tempFileNameWithoutExtension = string.Empty;
                    foreach (var text in URLParts)
                    {
                        if (text.Contains("http://") || text.Contains("https://"))
                        {
                            if (text.Contains("?"))
                            {
                                resultURL = text.Trim('?');
                            }
                            else
                            {
                                resultURL = text;
                            }
                            break;
                        }
                    }
                    tempFileName = Path.GetFileName(resultURL).Replace("%20", " ");
                    tempFileNameWithoutExtension = Path.GetFileNameWithoutExtension(resultURL).Replace("%20", " ");

                    #endregion Get filename from URL

                    #region Get file extension
                    string fileNameExtension = Path.GetExtension(tempFileName);
                    #endregion Get file extension

                    #region Filename without extension to Base64 string

                    /*
                     * The file name will be converted to base64 string to remove space
                     * and to be able to recover the original file name later
                     */
                    byte[] tempFileNameInBytes = Encoding.UTF8.GetBytes(tempFileName);
                    byte[] tempFileNameWithoutExtensionInBytes = Encoding.UTF8.GetBytes(tempFileNameWithoutExtension);

                    string localFileName = Convert.ToBase64String(tempFileNameInBytes) + fileNameExtension;
                    string localFileNameWithoutExtension = Convert.ToBase64String(tempFileNameWithoutExtensionInBytes) + fileNameExtension;
                    #endregion Filename without extension to Base64 string

                    #endregion File name processing

                    #region Working directory setup (second phase)

                    #region Temporary download location setup

                    string temporaryDownloadLocation = string.Empty;
                    if (temporaryWorkingDirectory.EndsWith("\\"))
                    {
                        temporaryDownloadLocation = temporaryWorkingDirectory + localFileName;
                    }
                    else
                    {
                        temporaryDownloadLocation = temporaryWorkingDirectory + "\\" + localFileName;
                    }
                    #endregion Temporary download location setup

                    #region Local processed directory (second phase)
                    if (processedVideoDirectory.EndsWith("\\"))
                    {
                        processedVideoDirectory += localFileNameWithoutExtension;
                    }
                    else
                    {
                        processedVideoDirectory += "\\" + localFileNameWithoutExtension;
                    }

                    if (!Directory.Exists(processedVideoDirectory))
                    {
                        Directory.CreateDirectory(processedVideoDirectory);
                    }
                    #endregion Local processed directory (second phase)

                    #region Network processed directory (second phase)
                    if (networkProcessedVideoDirectory.EndsWith("/"))
                    {
                        networkProcessedVideoDirectory += localFileNameWithoutExtension;
                    }
                    else
                    {
                        networkProcessedVideoDirectory += "/" + localFileNameWithoutExtension;
                    }
                    #endregion Network processed directory (second phase)

                    #endregion Working directory download location (Second phase)

                    #region File download
                    try
                    {
                        using (var client = new WebClient())
                        {
                            client.DownloadFile(videoInformation.VideoLocations.VideoLocation, temporaryDownloadLocation);
                        }
                    }
                    catch (Exception err)
                    {
                        videoInfo.result = Result.Fail;
                        return(videoInfo);
                    }

                    #endregion File download

                    #region VideoProcessing.exe argument configurations
                    string arguments = "GetFrames ";

                    #region Temporary location (Source file)
                    if (temporaryDownloadLocation.Contains("\""))
                    {
                        arguments += temporaryDownloadLocation + " ";
                    }
                    else
                    {
                        arguments += "\"" + temporaryDownloadLocation + "\" ";
                    }
                    #endregion Temporary location (Source file)

                    #region Target directory
                    if (processedVideoDirectory.Contains("\""))
                    {
                        arguments += processedVideoDirectory + " ";
                    }
                    else
                    {
                        arguments += "\"" + processedVideoDirectory + "\"";
                    }
                    #endregion Target directory

                    #region Scaling
                    if (videoHeight > 0)
                    {
                        if (videoHeight > 0)
                        {
                            arguments += " height=" + videoHeight;
                        }
                        else
                        {
                            arguments += " height=-1";
                        }
                    }
                    #endregion Scaling

                    #region Request delete original
                    //if (deleteTemporaryVideoWhenFinished)
                    //{
                    //    // += " request_delete=true";
                    //}
                    #endregion Request delete original

                    #region FPS overriding
                    if (videoInformation.VideoSetting.frameRate == FrameRate.Other)
                    {
                        arguments += " FPS=" + videoInformation.VideoSetting.FPS;
                    }
                    else if (videoInformation.VideoSetting.frameRate == FrameRate.Default)
                    {
                    }
                    else
                    {
                        arguments += " FPS=" + (int)videoInformation.VideoSetting.frameRate;
                    }
                    #endregion FPS overriding

                    #region Audio processing
                    arguments += " with_audio=true";
                    #endregion Audio processing

                    #region Requester
                    arguments += " requester=mediaplayer";
                    arguments += " sessionid=" + userInfo.SessionID;
                    arguments += " printinfo=true";
                    #endregion Requester
                    #endregion VideoProcessing.exe argument configurations

                    #region Video info extraction
                    VideoProcessor.ApplicationSettings applicationSettings = new VideoProcessor.ApplicationSettings();
                    applicationSettings.useCustomApplication = true;
                    applicationSettings.FFmpegPath           = systemConfiguration.FFmpegLocation;
                    applicationSettings.FFProbePath          = systemConfiguration.FFProbeLocation;
                    VideoProcessor.VideoProcessor processor = new VideoProcessor.VideoProcessor(applicationSettings);
                    #endregion Video info extraction

                    #region Generate info

                    #region File location informations
                    videoInfo.videoSource           = videoInformation.VideoLocations.VideoLocation;
                    videoInfo.networkAccessLocation = networkProcessedVideoDirectory;
                    videoInfo.localAccessLocation   = processedVideoDirectory;
                    #endregion File location informations

                    #region Video name
                    //videoInfo.videoName = tempFileNameWithoutExtension;
                    videoInfo.videoName          = tempFileName;
                    videoInfo.processedVideoName = localFileNameWithoutExtension;
                    #endregion Video name

                    #region Video frame rate
                    if (videoInformation.VideoSetting.frameRate == FrameRate.Other)
                    {
                        videoInfo.frameRate = videoInformation.VideoSetting.FPS;
                    }
                    else if (videoInformation.VideoSetting.frameRate == FrameRate.Default)
                    {
                        videoInfo.frameRate = processor.GetFrameRate(temporaryDownloadLocation);
                        //videoInfo.frameRate = -1;
                    }
                    else
                    {
                        videoInfo.frameRate = (double)videoInformation.VideoSetting.frameRate;
                    }
                    #endregion Video frame rate

                    #region Local video save location
                    //if (processedVideoDirectory.EndsWith("\\"))
                    //{
                    //    videoInfo.localAccessLocation = processedVideoDirectory + localFileName;
                    //}
                    //else
                    //{
                    //    videoInfo.localAccessLocation = processedVideoDirectory + "\\" + localFileName;
                    //}
                    #endregion Local video save location

                    #region Network video save location
                    videoInfo.networkAccessLocation = networkProcessedVideoDirectory;
                    #endregion Network video save location

                    #region Video duration
                    videoInfo.videoDuration = processor.GetTotalDuration(temporaryDownloadLocation).TotalSeconds;
                    #endregion Video duration

                    #region Video info

                    #region Video frame informations
                    videoInfo.startFrame = 1;

                    if (videoInformation.VideoSetting.frameRate == FrameRate.Default)
                    {
                        videoInfo.endFrame = processor.GetTotalFrames(temporaryDownloadLocation);
                    }
                    else if (videoInformation.VideoSetting.frameRate == FrameRate.Other)
                    {
                        videoInfo.endFrame = Convert.ToInt32(videoInfo.videoDuration * videoInformation.VideoSetting.FPS);
                    }
                    else
                    {
                        videoInfo.endFrame = Convert.ToInt32(videoInfo.videoDuration * (double)videoInformation.VideoSetting.frameRate);
                    }
                    #endregion Video frame informations

                    videoInfo.videoHeight = videoHeight;
                    #endregion Video info

                    #endregion Generate info

                    #region Video information registration
                    //Re-read user settings
                    VideoPlayerSettings settings = HelperClass.ReadPlayerSettings(userInfo.SessionID, "MediaPlayerDatabase", "UserSettings", systemConfiguration.DatabaseProcessingConfiguration.DatabaseConectionString);

                    // Add process to database
                    HelperClass.SetVideoInfo(settings, userInfo, videoInfo);

                    // Get process ID
                    int processID = SQLClassPeralatan.Peralatan.NilaiTertinggi("MediaPlayerDatabase", "ProcessedVideoInfo", "ProcessID", "UserID", userInfo.UserID.ToString(), systemConfiguration.DatabaseProcessingConfiguration.DatabaseConectionString);
                    videoInfo.processID = processID;
                    #endregion Video information registration

                    #region VideoProcessing.exe additional argument
                    //arguments += " processid=" + processID;
                    #endregion VideoProcessing.exe additional argument

                    #region Program execution
                    startInfo.Arguments = arguments;
                    if (ConfigurationManager.AppSettings["VideoProcessingWindowType"] == "Normal")
                    {
                        startInfo.WindowStyle = ProcessWindowStyle.Normal;
                    }
                    else
                    {
                        startInfo.WindowStyle = ProcessWindowStyle.Hidden;
                    }
                    startInfo.UseShellExecute = true;
                    Process.Start(startInfo);
                    #endregion Program execution

                    //TODO Cleanup file
                    #region Cleanup

                    /*
                     * For now, the clean up of temporary downloaded file will be
                     * hanlded by external application.
                     * The reason is because there's an external application and
                     * to prevent the external application from getting error.
                     */

                    videoInfo.result = Result.Success;
                    #endregion Cleanup

                    return(videoInfo);
                }
                else
                {
                    videoInfo.result  = Result.Fail;
                    videoInfo.message = "Video playing with protocol other than http is not supported";
                    return(videoInfo);
                }
            }
            else
            {
                #region Preparation
                ProcessStartInfo startInfo      = new ProcessStartInfo(systemConfiguration.VideoProcessorLocation);
                FFProbe          fFProbe        = new FFProbe();
                ProcessedVideo   processedVideo = new ProcessedVideo();

                #region Working directories
                string processedVideoSaveLocation     = systemConfiguration.ProcessedVideoSaveLocation;
                string networkProcessedVideoDirectory = string.Empty;
                string processedVideoDirectory        = string.Empty;
                #endregion Working directories

                #endregion Preparation

                #region Video information
                string localVideoName = string.Empty;
                string localVideoNameWithoutExtension = string.Empty;
                string videoExtension = string.Empty;

                string localVideoNameInBase64 = string.Empty;
                #region File name processing

                #region Video file name
                localVideoName = Path.GetFileName(videoInformation.VideoLocations.VideoLocation);
                localVideoNameWithoutExtension = Path.GetFileNameWithoutExtension(localVideoName);
                videoExtension = Path.GetExtension(localVideoName);
                #endregion Video file name

                #region Video file name in Base64 format
                localVideoNameInBase64 = Convert.ToBase64String(Encoding.UTF8.GetBytes(localVideoName));
                #endregion Video file name in Base64 format
                #endregion File name processing

                #region Video settings
                int videoHeight;
                if (videoInformation.VideoSetting.processedVideoResolution == Resolution.Other)
                {
                    videoHeight = videoInformation.VideoSetting.height;
                }
                else if (videoInformation.VideoSetting.processedVideoResolution == Resolution.Original)
                {
                    videoHeight = -1;
                }
                else
                {
                    videoHeight = (int)videoInformation.VideoSetting.processedVideoResolution;
                }
                #endregion Video settings

                #endregion Video information

                #region Directory setup

                #region Processed video directory
                if (videoInformation.VideoLocations.videoSaveLocation == "default")
                {
                    throw new NotImplementedException("Custom path is not yet supported.");
                    //if (videoInformation.VideoLocations.videoSaveLocation.EndsWith("\\"))
                    //{
                    //    processedVideoDirectory = videoInformation.VideoLocations.videoSaveLocation + ID;
                    //}
                    //else
                    //{
                    //    processedVideoDirectory = videoInformation.VideoLocations.videoSaveLocation + "\\" + ID;
                    //}
                    ////Check for directory
                    //if (!Directory.Exists(processedVideoDirectory))
                    //{
                    //    Directory.CreateDirectory(processedVideoDirectory);
                    //}
                }
                else
                {
                    if (processedVideoSaveLocation.EndsWith("\\"))
                    {
                        processedVideoDirectory = processedVideoSaveLocation + userInfo.SessionID;
                    }
                    else
                    {
                        processedVideoDirectory = processedVideoSaveLocation + "\\" + userInfo.SessionID;
                    }

                    //Check for directory
                    if (!Directory.Exists(processedVideoDirectory))
                    {
                        Directory.CreateDirectory(processedVideoDirectory);
                    }
                }

                if (processedVideoDirectory.EndsWith("\\"))
                {
                    processedVideoDirectory += localVideoNameInBase64;
                }
                else
                {
                    processedVideoDirectory += "\\" + localVideoNameInBase64;
                }

                if (!Directory.Exists(processedVideoDirectory))
                {
                    Directory.CreateDirectory(processedVideoDirectory);
                }
                #endregion Processed video directory

                #region Network processed video directory
                if (!Directory.Exists(processedVideoDirectory))
                {
                    throw new Exception("Cannot create network folder if local folder isn't available.");
                }
                if (videoInformation.VideoLocations.videoNetworkSaveLocation.EndsWith("/"))
                {
                    networkProcessedVideoDirectory = videoInformation.VideoLocations.videoNetworkSaveLocation + userInfo.SessionID + "/";
                }
                else
                {
                    networkProcessedVideoDirectory = videoInformation.VideoLocations.videoNetworkSaveLocation + "/" + userInfo.SessionID + "/";
                }

                if (networkProcessedVideoDirectory.EndsWith("/"))
                {
                    networkProcessedVideoDirectory += localVideoNameInBase64;
                }
                else
                {
                    networkProcessedVideoDirectory += "/" + localVideoNameInBase64;
                }
                #endregion Network processed video directory

                #endregion Directory setup

                #region VideoProcessing.exe argument configurations
                string arguments = "GetFrames ";

                #region Source file
                if (videoInformation.VideoLocations.VideoLocation.Contains("\""))
                {
                    arguments += videoInformation.VideoLocations.VideoLocation + " ";
                }
                else
                {
                    arguments += "\"" + videoInformation.VideoLocations.VideoLocation + "\" ";
                }
                #endregion Source file

                #region Target directory
                if (processedVideoDirectory.Contains("\""))
                {
                    arguments += processedVideoDirectory + " ";
                }
                else
                {
                    arguments += "\"" + processedVideoDirectory + "\"";
                }
                #endregion Target directory

                #region Scaling
                if (videoHeight > 0)
                {
                    if (videoHeight > 0)
                    {
                        arguments += " height=" + videoHeight;
                    }
                }
                #endregion Scaling

                #region Request delete original
                //if (deleteTemporaryVideoWhenFinished)
                //{
                //    // += " request_delete=true";
                //}
                #endregion Request delete original

                #region FPS overriding
                if (videoInformation.VideoSetting.frameRate == FrameRate.Other)
                {
                    arguments += " FPS=" + videoInformation.VideoSetting.FPS;
                }
                else if (videoInformation.VideoSetting.frameRate == FrameRate.Default)
                {
                }
                else
                {
                    arguments += " FPS=" + (int)videoInformation.VideoSetting.frameRate;
                }
                #endregion FPS overriding

                #region Audio processing
                arguments += " with_audio=true";
                #endregion Audio processing

                #region Requester
                arguments += " requester=mediaplayer";
                arguments += " sessionid=" + userInfo.SessionID;
                arguments += " printinfo=true";
                #endregion Requester
                #endregion VideoProcessing.exe argument configurations

                #region Video info extraction
                VideoProcessor.ApplicationSettings applicationSettings = new VideoProcessor.ApplicationSettings();
                applicationSettings.useCustomApplication = true;
                applicationSettings.FFmpegPath           = systemConfiguration.FFmpegLocation;
                applicationSettings.FFProbePath          = systemConfiguration.FFProbeLocation;
                VideoProcessor.VideoProcessor processor = new VideoProcessor.VideoProcessor(applicationSettings);
                #endregion Video info extraction

                #region Processed video information

                #region File location informations
                processedVideo.videoSource           = videoInformation.VideoLocations.VideoLocation;
                processedVideo.networkAccessLocation = networkProcessedVideoDirectory;
                processedVideo.localAccessLocation   = processedVideoDirectory;
                #endregion File location informations

                #region Video name
                //processedVideo.videoName = tempFileNameWithoutExtension;
                processedVideo.processedVideoName = localVideoNameInBase64;
                #endregion Video name

                #region Video frame rate
                if (videoInformation.VideoSetting.frameRate == FrameRate.Other)
                {
                    processedVideo.frameRate = videoInformation.VideoSetting.FPS;
                }
                else if (videoInformation.VideoSetting.frameRate == FrameRate.Default)
                {
                    processedVideo.frameRate = processor.GetFrameRate(videoInformation.VideoLocations.VideoLocation);
                }
                else
                {
                    processedVideo.frameRate = (double)videoInformation.VideoSetting.frameRate;
                }
                #endregion Video frame rate

                #region Local video save location
                //processedVideo.localAccessLocation = videoInformation.VideoLocations.VideoLocation;
                #endregion Local video save location

                #region Network video save location
                processedVideo.networkAccessLocation = networkProcessedVideoDirectory;
                #endregion Network video save location

                #region Video duration
                processedVideo.videoDuration = processor.GetTotalDuration(videoInformation.VideoLocations.VideoLocation).TotalSeconds;
                #endregion Video duration

                #region Video frame information

                #region Video frame informations
                processedVideo.startFrame = 1;

                if (videoInformation.VideoSetting.frameRate == FrameRate.Default)
                {
                    processedVideo.endFrame = processor.GetTotalFrames(videoInformation.VideoLocations.VideoLocation);
                }
                else if (videoInformation.VideoSetting.frameRate == FrameRate.Other)
                {
                    processedVideo.endFrame = Convert.ToInt32(processedVideo.videoDuration * videoInformation.VideoSetting.FPS);
                }
                else
                {
                    processedVideo.endFrame = Convert.ToInt32(processedVideo.videoDuration * (double)videoInformation.VideoSetting.frameRate);
                }
                #endregion Video frame informations

                processedVideo.videoHeight = videoHeight;
                #endregion Video frame information

                #endregion Processed video information

                #region Video information registration
                //Re-read user settings
                VideoPlayerSettings settings = HelperClass.ReadPlayerSettings(userInfo.SessionID, "MediaPlayerDatabase", "UserSettings", systemConfiguration.DatabaseProcessingConfiguration.DatabaseConectionString);

                // Add process to database
                HelperClass.SetVideoInfo(settings, userInfo, processedVideo);

                // Get process ID
                int processID = SQLClassPeralatan.Peralatan.NilaiTertinggi("MediaPlayerDatabase", "ProcessedVideoInfo", "ProcessID", "UserID", userInfo.UserID.ToString(), systemConfiguration.DatabaseProcessingConfiguration.DatabaseConectionString);
                processedVideo.processID = processID;
                #endregion Video information registration

                #region VideoProcessing.exe additional argument
                //arguments += " processid=" + processID;
                #endregion VideoProcessing.exe additional argument

                #region Program execution
                startInfo.Arguments = arguments;
                if (ConfigurationManager.AppSettings["VideoProcessingWindowType"] == "Normal")
                {
                    startInfo.WindowStyle = ProcessWindowStyle.Normal;
                }
                else
                {
                    startInfo.WindowStyle = ProcessWindowStyle.Hidden;
                }
                startInfo.UseShellExecute = true;
                Process.Start(startInfo);
                #endregion Program execution

                #region Cleanup

                /*
                 * For now, the clean up of temporary downloaded file will be
                 * hanlded by external application.
                 * The reason is because there's an external application and
                 * to prevent the external application from getting error.
                 */

                processedVideo.result = Result.Success;
                #endregion Cleanup
                return(processedVideo);
            }
        }
Пример #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            CSSLoader();
            //savedSettings = HelperClass.ReadPlayerSettings(Session.SessionID, settingsDatabase, settingsTable, connectionString);

            #region Preparation

            #region System setting loading
            SystemConfiguration systemConfiguration = HelperClass.SystemConfigurationLoader();
            #endregion System setting loading

            #region User info loading
            UserInfo userInfo = new UserInfo {
                SessionID = Session.SessionID
            };

            // Try reading user information
            try
            {
                if (HelperClass.CheckUser("MediaPlayerDatabase", "SessionInfo", userInfo.SessionID, systemConfiguration.DatabaseProcessingConfiguration.DatabaseConectionString))
                {
                    // Load user info
                    SQLClassPeralatan.MintaDataDatabase mintaDataDatabase = new SQLClassPeralatan.MintaDataDatabase("UserID", "SessionInfo", "SessionID", userInfo.SessionID, systemConfiguration.DatabaseProcessingConfiguration.DatabaseConectionString);
                    userInfo.UserID = Convert.ToInt32(mintaDataDatabase.DataDiterima);
                }
                else
                {
                    // Add user info
                    if (HelperClass.AddUser("MediaPlayerDatabase", "SessionInfo", userInfo.SessionID, systemConfiguration.DatabaseProcessingConfiguration.DatabaseConectionString))
                    {
                        // Read user id
                        SQLClassPeralatan.MintaDataDatabase mintaDataDatabase = new SQLClassPeralatan.MintaDataDatabase("UserID", "SessionInfo", "SessionID", userInfo.SessionID, systemConfiguration.DatabaseProcessingConfiguration.DatabaseConectionString);
                        if (!mintaDataDatabase.TerdapatKesalahan)
                        {
                            userInfo.UserID = Convert.ToInt32(mintaDataDatabase.DataDiterima);
                        }
                        else
                        {
                            Response.Redirect("Error.aspx?id=21");
                        }
                    }
                    else
                    {
                        Response.Redirect("Error.aspx?id=23");
                    }
                }
            }
            catch (Exception err)
            {
                Response.Redirect("Error.aspx?id=21&message=" + err.Message);
            }
            #endregion User info loading

            #region User player configuration loading
            VideoPlayerSettings userPlayerSetting = new VideoPlayerSettings();

            try
            {
                if (!IsPostBack)
                {
                    // Check user player configuration
                    if (HelperClass.CheckSettings("MediaPlayerDatabase", userInfo, "UserSettings", systemConfiguration.DatabaseProcessingConfiguration.DatabaseConectionString))
                    {
                        userPlayerSetting = HelperClass.ReadPlayerSettings(userInfo.SessionID, "MediaPlayerDatabase", "UserSettings", systemConfiguration.DatabaseProcessingConfiguration.DatabaseConectionString);
                    }
                    else
                    {
                        if (HelperClass.CreateNewSettings("MediaPlayerDatabase", "UserSettings", userInfo, systemConfiguration.DatabaseProcessingConfiguration.DatabaseConectionString))
                        {
                            userPlayerSetting = HelperClass.ReadPlayerSettings(userInfo.SessionID, "MediaPlayerDatabase", "UserSettings", systemConfiguration.DatabaseProcessingConfiguration.DatabaseConectionString);
                        }
                        else
                        {
                            Response.Redirect("Error.aspx?id=24&message=Maybe a server problem");
                        }
                    }
                }
            }
            catch (Exception err)
            {
                Response.Redirect("Error.aspx?id=24&message=" + err.Message);
            }
            #endregion User player configuration loading

            #endregion Preparation

            if (!IsPostBack)
            {
                lstVideoResolution.SelectedValue = ((int)userPlayerSetting.resolution).ToString();
                lstFrameRate.SelectedValue       = ((int)userPlayerSetting.frameRate).ToString();
                lstFrameBufferMode.SelectedValue = ((int)userPlayerSetting.bufferMode).ToString();
                lstFramePreload.SelectedValue    = ((int)userPlayerSetting.preloadFrames).ToString();
                lstPlayMode.SelectedIndex        = 0;
            }
        }
Пример #7
0
        protected void btnSaveSettings_Click(object sender, EventArgs e)
        {
            #region Preparation
            VideoPlayerSettings settings            = new VideoPlayerSettings();
            SystemConfiguration systemConfiguration = HelperClass.SystemConfigurationLoader();
            UserInfo            userInfo            = new UserInfo();
            #endregion Preparation

            #region User info loading
            userInfo.SessionID = Session.SessionID;
            // Try reading user information
            if (HelperClass.CheckUser("MediaPlayerDatabase", "SessionInfo", userInfo.SessionID, systemConfiguration.DatabaseProcessingConfiguration.DatabaseConectionString))
            {
                // Load user info
                SQLClassPeralatan.MintaDataDatabase mintaDataDatabase = new SQLClassPeralatan.MintaDataDatabase("UserID", "SessionInfo", "SessionID", userInfo.SessionID, systemConfiguration.DatabaseProcessingConfiguration.DatabaseConectionString);
                userInfo.UserID = Convert.ToInt32(mintaDataDatabase.DataDiterima);
            }
            else
            {
                Response.Redirect("Error.aspx?id=21");
            }
            #endregion User info loading

            #region Resolution
            int selectedResolution = Convert.ToInt32(lstVideoResolution.SelectedValue);

            if (selectedResolution == (int)Resolution.Original)
            {
                settings.resolution = Resolution.Original;
            }
            else if (selectedResolution == (int)Resolution.SD_360p)
            {
                settings.resolution = Resolution.SD_360p;
            }
            else if (selectedResolution == (int)Resolution.SD_480p)
            {
                settings.resolution = Resolution.SD_480p;
            }
            else if (selectedResolution == (int)Resolution.HD_720p)
            {
                settings.resolution = Resolution.HD_720p;
            }
            else if (selectedResolution == (int)Resolution.HD_1080p)
            {
                settings.resolution = Resolution.HD_1080p;
            }
            else if (selectedResolution == (int)Resolution.SUHD_1440p)
            {
                settings.resolution = Resolution.SUHD_1440p;
            }
            else
            {
                settings.resolution = Resolution.Other;
            }
            #endregion Resolution

            #region Framerate
            int selectedFramerate = Convert.ToInt32(lstFrameRate.SelectedValue);
            if (selectedFramerate == (int)FrameRate.Default)
            {
                settings.frameRate = FrameRate.Default;
            }
            else if (selectedFramerate == (int)FrameRate._24fps)
            {
                settings.frameRate = FrameRate._24fps;
            }
            else if (selectedFramerate == (int)FrameRate._30fps)
            {
                settings.frameRate = FrameRate._30fps;
            }
            else if (selectedFramerate == (int)FrameRate._60fps)
            {
                settings.frameRate = FrameRate._60fps;
            }
            else if (selectedFramerate == (int)FrameRate._120fps)
            {
                settings.frameRate = FrameRate._120fps;
            }
            else
            {
                settings.frameRate = FrameRate.Other;
            }
            #endregion Framerate

            #region Buffer mode
            int selectedBufferMode = Convert.ToInt32(lstFrameBufferMode.SelectedValue);

            if (selectedBufferMode == (int)BufferMode.SingleBuffer)
            {
                settings.bufferMode = BufferMode.SingleBuffer;
            }
            else if (selectedBufferMode == (int)BufferMode.DoubleBuffer)
            {
                settings.bufferMode = BufferMode.DoubleBuffer;
            }
            else
            {
                settings.bufferMode = BufferMode.TripleBuffer;
            }
            #endregion Buffer mode

            #region Frame preload
            int selectedFramePreload = Convert.ToInt32(lstFramePreload.SelectedValue);

            if (selectedFramePreload == (int)PreloadFrames.EnablePreload)
            {
                settings.preloadFrames = PreloadFrames.EnablePreload;
            }
            else
            {
                settings.preloadFrames = PreloadFrames.DisablePreload;
            }

            #endregion Frame preload

            FunctionResult result = HelperClass.UpdateSettings(settings, userInfo, "MediaPlayerDatabase", "UserSettings", connectionString);
            if (result.functionResult == Result.Fail)
            {
                Response.Redirect("Error.aspx?id=25");
            }
            Response.Redirect("Index.aspx");
        }
Пример #8
0
        public static DatabaseProcessedInfo SetVideoInfo(VideoPlayerSettings settings, UserInfo userInfo, ProcessedVideo processedVideo)
        {
            #region Preparation
            DatabaseProcessedInfo result = new DatabaseProcessedInfo();

            string SQLCommand       = string.Empty;
            string connectionString = string.Empty;

            string UserID           = string.Empty;
            string OriginalVideoURL = string.Empty;
            string OriginalTemporaryVideoLocation = string.Empty;
            string LocalProcessedVideoLocation    = string.Empty;
            string NetworkProcessedVideoLocation  = string.Empty;
            string OriginalVideoWidth             = string.Empty;
            string OriginalVideoHeight            = string.Empty;
            string VideoDuration           = string.Empty;
            string VideoFrameRate          = string.Empty;
            string VideoCalculatedEndFrame = string.Empty;
            string VideoActualEndFrame     = string.Empty;
            string VideoTotalFrames        = string.Empty;
            string Scaled         = string.Empty;
            string ScaledWidth    = string.Empty;
            string ScaledHeight   = string.Empty;
            string WithAudio      = string.Empty;
            string DateProcessed  = string.Empty;
            string DateLastAccess = string.Empty;
            string VideoStatus    = string.Empty;
            string LogID          = string.Empty;
            #endregion Preparation

            // Info prefetch
            UserID = userInfo.UserID.ToString();

            #region Data modification
            byte[] originalURLinBytes = Encoding.UTF8.GetBytes(processedVideo.videoSource);
            OriginalVideoURL = Convert.ToBase64String(originalURLinBytes);

            byte[] localFileinBytes = Encoding.UTF8.GetBytes(processedVideo.localAccessLocation);
            LocalProcessedVideoLocation = Convert.ToBase64String(localFileinBytes);

            byte[] networkFileinBytes = Encoding.UTF8.GetBytes(processedVideo.networkAccessLocation);
            NetworkProcessedVideoLocation = Convert.ToBase64String(networkFileinBytes);
            #endregion Data modification

            // Video info data
            SQLCommand  = "USE MediaPlayerDatabase;";
            SQLCommand += "INSERT INTO ProcessedVideoInfo (";
            // Table column
            SQLCommand += "UserID, ";
            SQLCommand += "OriginalVideoURL, ";
            //SQLCommand += "OriginalTemporaryVideoFolder, ";
            SQLCommand += "LocalProcessedVideoFolder, ";
            SQLCommand += "NetworkProcessedVideoFolder, ";
            SQLCommand += "OriginalVideoWidth, ";
            SQLCommand += "OriginalVideoHeight, ";
            SQLCommand += "VideoDuration, ";
            SQLCommand += "VideoFrameRate, ";
            SQLCommand += "VideoCalculatedEndFrame, ";
            SQLCommand += "VideoActualEndFrame, ";
            //SQLCommand += "VideoTotalFrames, ";
            SQLCommand += "Scaled, ";
            SQLCommand += "ScaledWidth, ";
            SQLCommand += "ScaledHeight, ";
            SQLCommand += "WithAudio, ";
            //SQLCommand += "DateProcessed, ";
            //SQLCommand += "DateLastAccess, ";
            SQLCommand += "VideoStatus";
            //SQLCommand += "LogID";
            // End table column
            // Table value
            SQLCommand += ") VALUES (";
            SQLCommand += UserID + ", ";
            SQLCommand += "'" + OriginalVideoURL + "', ";
            SQLCommand += "'" + LocalProcessedVideoLocation + "', ";
            SQLCommand += "'" + NetworkProcessedVideoLocation + "', ";
            SQLCommand += processedVideo.videoWidth + ", ";
            SQLCommand += processedVideo.videoHeight + ", ";
            SQLCommand += "'" + processedVideo.videoDuration + "', ";
            SQLCommand += "'" + processedVideo.frameRate + "', ";
            SQLCommand += processedVideo.endFrame + ", ";
            //SQLCommand += "0, ";
            SQLCommand += "0, ";
            if (settings.resolution == Resolution.Original)
            {
                SQLCommand += "FALSE, ";
            }
            else
            {
                SQLCommand += "1, ";
                SQLCommand += "0, ";
                SQLCommand += ((int)settings.resolution).ToString() + ", ";
            }
            SQLCommand += "1, ";
            SQLCommand += "1);";

            if (Peralatan.TambahKeDatabase(SQLCommand, connectionString))
            {
                result.videoStatus = ProcessedStatus.Processed;
                result.HasMessage  = false;
            }
            else
            {
                result.HasMessage = true;
                result.Message    = Peralatan.PesanKesalahan;
            }

            return(result);
        }
Пример #9
0
        public static VideoPlayerSettings ReadPlayerSettings(string sessionID, string database, string table, string connectionString)
        {
            VideoPlayerSettings UserSettings = new VideoPlayerSettings();

            string userID = Peralatan.MintaDataDatabase(database, "UserID", "SessionInfo", "SessionID", sessionID, connectionString);

            #region Video
            string receivedHeight = Peralatan.MintaDataDatabase(database, "VideoHeight", table, "UserID", userID, connectionString);
            if (receivedHeight == ((int)Resolution.Original).ToString())
            {
                UserSettings.resolution = Resolution.Original;
            }
            else if (receivedHeight == ((int)Resolution.SD_360p).ToString())
            {
                UserSettings.resolution = Resolution.SD_360p;
            }
            else if (receivedHeight == ((int)Resolution.SD_480p).ToString())
            {
                UserSettings.resolution = Resolution.SD_480p;
            }
            else if (receivedHeight == ((int)Resolution.HD_720p).ToString())
            {
                UserSettings.resolution = Resolution.HD_720p;
            }
            else if (receivedHeight == ((int)Resolution.HD_1080p).ToString())
            {
                UserSettings.resolution = Resolution.HD_1080p;
            }
            else if (receivedHeight == ((int)Resolution.SUHD_1440p).ToString())
            {
                UserSettings.resolution = Resolution.SUHD_1440p;
            }
            else
            {
                UserSettings.resolution = Resolution.SD_480p;
            }
            #endregion Video resolution

            #region Video framerate
            string receivedFrameRate = Peralatan.MintaDataDatabase(database, "FrameRate", table, "UserID", userID, connectionString);
            if (receivedFrameRate == ((int)FrameRate.Default).ToString())
            {
                UserSettings.frameRate = FrameRate.Default;
            }
            else if (receivedFrameRate == ((int)FrameRate._24fps).ToString())
            {
                UserSettings.frameRate = FrameRate._24fps;
            }
            else if (receivedFrameRate == ((int)FrameRate._30fps).ToString())
            {
                UserSettings.frameRate = FrameRate._30fps;
            }
            else if (receivedFrameRate == ((int)FrameRate._60fps).ToString())
            {
                UserSettings.frameRate = FrameRate._60fps;
            }
            else if (receivedFrameRate == ((int)FrameRate._120fps).ToString())
            {
                UserSettings.frameRate = FrameRate._120fps;
            }
            else
            {
                UserSettings.frameRate = FrameRate.Default;
            }
            #endregion Video framerate

            #region Video buffer mode
            string receivedBufferMode = Peralatan.MintaDataDatabase(database, "BufferMode", table, "UserID", userID, connectionString);
            if (receivedBufferMode == ((int)BufferMode.SingleBuffer).ToString())
            {
                UserSettings.bufferMode = BufferMode.SingleBuffer;
            }
            else if (receivedBufferMode == ((int)BufferMode.DoubleBuffer).ToString())
            {
                UserSettings.bufferMode = BufferMode.DoubleBuffer;
            }
            else if (receivedBufferMode == ((int)BufferMode.TripleBuffer).ToString())
            {
                UserSettings.bufferMode = BufferMode.TripleBuffer;
            }
            else
            {
                UserSettings.bufferMode = BufferMode.SingleBuffer;
            }
            #endregion Video buffer mode

            #region Video preload frames
            string receivedPreload = Peralatan.MintaDataDatabase(database, "PreloadFrames", table, "UserID", userID, connectionString);
            if (receivedPreload == ((int)PreloadFrames.DisablePreload).ToString())
            {
                UserSettings.preloadFrames = PreloadFrames.DisablePreload;
            }
            else if (receivedPreload == ((int)PreloadFrames.EnablePreload).ToString())
            {
                UserSettings.preloadFrames = PreloadFrames.EnablePreload;
            }
            else
            {
                UserSettings.preloadFrames = PreloadFrames.DisablePreload;
            }
            #endregion Video preload frames
            return(UserSettings);
        }
Пример #10
0
        protected void btnUploadVideo_Click(object sender, EventArgs e)
        {
            #region Preparation

            #region Initialization

            #region Database configuration
            string databaseName  = "MediaPlayerDatabase";
            string userTableName = "SessionInfo";
            string settingsTable = "UserSettings";
            #endregion Database configuration

            #region Processor initialization
            Processor mainProcessor = new Processor();
            #endregion Processor initialization

            #region User information
            UserInfo userInfo = new UserInfo();
            #endregion User information

            #region Video processing information
            string                     videoName = string.Empty;
            string                     videoNameWithoutExtension  = string.Empty;
            ProcessedVideo             processedVideo             = new ProcessedVideo();
            VideoProcessingInformation videoProcessingInformation = new VideoProcessingInformation();
            #endregion Video processing information

            #endregion Initialization

            #region System configuration loader
            SystemConfiguration systemConfiguration = HelperClass.SystemConfigurationLoader();
            #endregion System configuration loader

            #region User information loader
            // Check for user information in database
            if (HelperClass.CheckUser(databaseName, userTableName, Session.SessionID, systemConfiguration.DatabaseProcessingConfiguration.DatabaseConectionString))
            {
                userInfo.SessionID = Session.SessionID;
                try
                {
                    userInfo.UserID = HelperClass.ReadUserInfo(Session.SessionID).UserID;
                }
                catch (Exception err)
                {
                    Response.Redirect("Error.aspx?id=22&message=" + err.Message);
                }
            }
            else
            {
                userInfo.SessionID = Session.SessionID;
                if (!HelperClass.AddUser(databaseName, userTableName, userInfo.SessionID, systemConfiguration.DatabaseProcessingConfiguration.DatabaseConectionString))
                {
                    Response.Redirect("Error.aspx?id=23");
                }

                try
                {
                    userInfo.UserID = HelperClass.ReadUserInfo(Session.SessionID).UserID;
                }
                catch (Exception err)
                {
                    Response.Redirect("Error.aspx?id=22&message=" + err.Message);
                }
            }
            #endregion User information loader

            #region Player settings loader
            VideoPlayerSettings settings = new VideoPlayerSettings();

            if (HelperClass.CheckSettings(databaseName, userInfo, settingsTable, systemConfiguration.DatabaseProcessingConfiguration.DatabaseConectionString))
            {
                settings = HelperClass.ReadPlayerSettings(Session.SessionID, database, settingsTable, connectionString);
            }
            else
            {
                if (HelperClass.CreateNewSettings(databaseName, settingsTable, userInfo, systemConfiguration.DatabaseProcessingConfiguration.DatabaseConectionString))
                {
                    settings = HelperClass.ReadPlayerSettings(Session.SessionID, database, settingsTable, connectionString);
                }
            }
            #endregion Player settings loader

            #region Video information preparation
            //processedVideo.videoName =  HttpUtility.UrlEncode(HelperClass.StringEncoderDecoder(Path.GetFileNameWithoutExtension(uplVideo.FileName), StringConversionMode.Encode));
            processedVideo.videoName = HttpUtility.UrlEncode(HelperClass.StringEncoderDecoder(Path.GetFileName(uplVideo.FileName), StringConversionMode.Encode));
            //processedVideo.processedVideoName = Convert.ToBase64String(Encoding.UTF8.GetBytes(processedVideo.videoName));
            #endregion Video information preparation

            #endregion Preparation

            #region File saving configuration

            //string saveLocation = string.Empty;

            bool requestDeleteFileAfterComplete = false;

            #region Temporary download location
            if (videoSaveLocation.EndsWith("\\"))
            {
                processedVideo.localAccessLocation = videoSaveLocation + Session.SessionID;
            }
            else
            {
                processedVideo.localAccessLocation = videoSaveLocation + "\\" + Session.SessionID;
            }

            // Path checking
            if (!Directory.Exists(processedVideo.localAccessLocation))
            {
                Directory.CreateDirectory(processedVideo.localAccessLocation);
            }

            if (processedVideo.localAccessLocation.EndsWith("\\"))
            {
                //processedVideo.localAccessLocation += processedVideo.processedVideoName + Path.GetExtension(uplVideo.FileName);
                processedVideo.localAccessLocation += Convert.ToBase64String(Encoding.UTF8.GetBytes(processedVideo.videoName)) + Path.GetExtension(uplVideo.FileName);
            }
            else
            {
                processedVideo.localAccessLocation += "\\" + Convert.ToBase64String(Encoding.UTF8.GetBytes(processedVideo.videoName)) + Path.GetExtension(uplVideo.FileName);;
            }
            #endregion Temporary download location


            #endregion File saving configuration

            #region Received info configuration
            string networkAccessLocation = string.Empty;
            //string videoName = string.Empty;
            string videoDuration = string.Empty;
            string frameRate     = string.Empty;
            string startFrame    = string.Empty;
            string endFrame      = string.Empty;
            string videoWidth    = string.Empty;
            string videoHeight   = string.Empty;

            #endregion Received info configuration

            #region Video saving
            uplVideo.SaveAs(processedVideo.localAccessLocation);

            //try
            //{
            //}
            //catch (Exception err)
            //{
            //    Response.Redirect("Error.aspx?id=202&message=" + err.Message);
            //    return;
            //}
            #endregion Video saving

            #region Information generation
            videoProcessingInformation.VideoLocations.VideoLocation            = processedVideo.localAccessLocation;
            videoProcessingInformation.VideoLocations.videoSaveLocation        = systemConfiguration.ProcessedVideoSaveLocation;
            videoProcessingInformation.VideoLocations.videoNetworkSaveLocation = systemConfiguration.NetworkProcessedVideoSaveLocation;
            videoProcessingInformation.VideoSetting.processedVideoResolution   = settings.resolution;
            videoProcessingInformation.VideoSetting.frameRate       = settings.frameRate;
            videoProcessingInformation.VideoSetting.audioProcessing = AudioProcessing.ProcessAudio;

            #endregion Information generation

            #region Video processing

            ProcessedVideo processedVideo2 = mainProcessor.ProcessVideo(videoProcessingInformation, systemConfiguration, userInfo, true);

            //VideoProcessingService.Service1Client client = new VideoProcessingService.Service1Client();
            //string[] receivedInfo = client.ProcessVideo2(saveLocation, true, Session.SessionID, true, 854, 480, 30);
            #endregion Video processing

            #region Result combination
            string temporaryData = processedVideo.videoName;
            processedVideo           = processedVideo2;
            processedVideo.videoName = temporaryData;
            #endregion Result combination

            #region Query string preparation
            string queryString = string.Empty;

            if (processedVideo.result == Result.Success)
            {
                queryString += "?new=true&";
                queryString += "mode=upload&";
                queryString += "path=" + processedVideo.networkAccessLocation + "&";
                queryString += "name=" + processedVideo.videoName + "&";
                queryString += "duration=" + processedVideo.videoDuration + "&";
                queryString += "framerate=" + processedVideo.frameRate + "&";
                queryString += "startframe=" + processedVideo.startFrame + "&";
                queryString += "endframe=" + processedVideo.endFrame + "&";
                queryString += "videoresolution=" + processedVideo.videoHeight + "&";
                queryString += "pid=" + processedVideo.processID;
                if (Convert.ToInt32(lstPlayingSpeed.SelectedValue) > 0)
                {
                    queryString += "&playspeed=" + lstPlayingSpeed.SelectedValue;
                }
                if (txtCustomPlayTime.Text != string.Empty)
                {
                    queryString += "&timeposition=" + txtCustomPlayTime.Text;
                }


                Response.Redirect("Player.aspx" + queryString);
            }
            else
            {
                Response.Redirect("Error.aspx?id=301");
            }

            #endregion Query string preparation

            // Transfer page
            Response.Redirect("Player.aspx" + queryString);
        }
Пример #11
0
        protected void btnLoadURLVideo_Click(object sender, EventArgs e)
        {
            if (mode == AccessMode.Web || mode == AccessMode.External)
            {
                #region In line commands
                // Used to check for commands (wihtout additional information)
                if (txtURLSource.Text.ToLower() == "help" || txtURLSource.Text.ToLower() == "bantuan")
                {
                    Response.Redirect("Help.aspx");
                }
                else if (txtURLSource.Text.ToLower() == "error")
                {
                    Response.Redirect("Error.aspx?id=100");
                }
                else if (txtURLSource.Text.ToLower() == "setting" || txtURLSource.Text.ToLower() == "settings")
                {
                    Response.Redirect("Settings.aspx");
                }
                else if (txtURLSource.Text.ToLower() == "player")
                {
                    Response.Redirect("Player.aspx");
                }
                else if (txtURLSource.Text.ToLower() == "sample1" || txtURLSource.Text.ToLower() == "sample2" || txtURLSource.Text.ToLower() == "sample3" || txtURLSource.Text.ToLower() == "sample4" || txtURLSource.Text.ToLower() == "sample5")
                {
                    Response.Redirect("Error.aspx?id=2");
                }
                else if (txtURLSource.Text.ToLower() == "checker")
                {
                    Response.Redirect("Checker.aspx?mode=sample");
                }
                #endregion In line commands

                #region Validation
                if (HelperClass.CheckWebsite(txtURLSource.Text))
                {
                    Uri uri = new Uri(txtURLSource.Text);
                    Response.Redirect("Error.aspx?id=902&message=" + uri.Host);
                }
                #endregion Validation

                #region (Old) Main Processing

                //#region Old main processing
                //#region Service initialization
                //VideoProcessingService.Service1Client videoProcessor = new VideoProcessingService.Service1Client();
                //#endregion Service initialization

                //#region Main process
                //string[] receivedVideoInfo = videoProcessor.ProcessVideo2(txtURLSource.Text, true, Session.SessionID, true, 0, (int)settings.resolution, (float)settings.frameRate);
                //#endregion Main process
                //#endregion Old main processing

                //#region Result processor
                //Stopwatch waitTime = new Stopwatch();
                //waitTime.Start();

                //if (receivedVideoInfo.Length == 0)
                //{
                //    System.Threading.Thread.Sleep(1000);
                //    if (waitTime.ElapsedMilliseconds == 20000)
                //    {
                //        waitTime.Stop();
                //        Response.Redirect("Error.aspx");
                //    }
                //}
                //videoProcessor.Close();
                //if (receivedVideoInfo[0].ToLower().Contains("error"))
                //{
                //    Response.Redirect("Error.aspx?id=10a");
                //}
                //else
                //{
                //    string queryString = string.Empty;
                //    queryString += "?new=true&";
                //    queryString += "path=" + receivedVideoInfo[1] + "&";
                //    queryString += "name=" + receivedVideoInfo[2] + "&";
                //    queryString += "duration=" + receivedVideoInfo[3] + "&";
                //    queryString += "framerate=" + receivedVideoInfo[4] + "&";
                //    queryString += "startframe=" + receivedVideoInfo[5] + "&";
                //    queryString += "endframe=" + receivedVideoInfo[6] + "&";
                //    queryString += "videowidth=" + receivedVideoInfo[7];
                //    Response.Redirect("Player.aspx" + queryString);
                //}
                //#endregion Result processor
                #endregion (Old) Main Processing

                #region  New processing
                #region Preparation
                string databaseName  = "MediaPlayerDatabase";
                string userTableName = "SessionInfo";
                string settingsTable = "UserSettings";

                Processor mainProcessor = new Processor();
                UserInfo  userInfo      = new UserInfo();
                VideoProcessingInformation videoProcessingInformation = new VideoProcessingInformation();

                #region System configuration loader
                SystemConfiguration systemConfiguration = HelperClass.SystemConfigurationLoader();
                #endregion System configuration loader

                #region User information loader
                // Check for user information in database
                if (HelperClass.CheckUser(databaseName, userTableName, Session.SessionID, systemConfiguration.DatabaseProcessingConfiguration.DatabaseConectionString))
                {
                    userInfo.SessionID = Session.SessionID;
                    try
                    {
                        userInfo.UserID = HelperClass.ReadUserInfo(Session.SessionID).UserID;
                    }
                    catch (Exception err)
                    {
                        Response.Redirect("Error.aspx?id=22&message=" + err.Message);
                    }
                }
                else
                {
                    userInfo.SessionID = Session.SessionID;
                    if (!HelperClass.AddUser(databaseName, userTableName, userInfo.SessionID, systemConfiguration.DatabaseProcessingConfiguration.DatabaseConectionString))
                    {
                        Response.Redirect("Error.aspx?id=23");
                    }
                    try
                    {
                        userInfo.UserID = HelperClass.ReadUserInfo(Session.SessionID).UserID;
                    }
                    catch (Exception err)
                    {
                        Response.Redirect("Error.aspx?id=22&message=" + err.Message);
                    }
                }
                #endregion User information loader

                #region Player settings loader
                VideoPlayerSettings settings = new VideoPlayerSettings();
                // Check settings
                if (HelperClass.CheckSettings(databaseName, userInfo, settingsTable, systemConfiguration.DatabaseProcessingConfiguration.DatabaseConectionString))
                {
                    settings = HelperClass.ReadPlayerSettings(Session.SessionID, database, settingsTable, connectionString);
                }
                else
                {
                    if (HelperClass.CreateNewSettings(databaseName, settingsTable, userInfo, systemConfiguration.DatabaseProcessingConfiguration.DatabaseConectionString))
                    {
                        settings = HelperClass.ReadPlayerSettings(Session.SessionID, database, settingsTable, connectionString);
                    }
                }
                #endregion Player settings loader

                #endregion Preparation;

                #region Information generation
                videoProcessingInformation.VideoLocations.VideoLocation            = txtURLSource.Text;
                videoProcessingInformation.VideoLocations.videoSaveLocation        = systemConfiguration.ProcessedVideoSaveLocation;
                videoProcessingInformation.VideoLocations.videoNetworkSaveLocation = systemConfiguration.NetworkProcessedVideoSaveLocation;
                videoProcessingInformation.VideoSetting.processedVideoResolution   = settings.resolution;
                videoProcessingInformation.VideoSetting.frameRate       = settings.frameRate;
                videoProcessingInformation.VideoSetting.audioProcessing = AudioProcessing.ProcessAudio;

                userInfo.SessionID = Session.SessionID;
                #endregion Information generation

                #region Main process
                ProcessedVideo processedVideo = mainProcessor.ProcessVideo(videoProcessingInformation, systemConfiguration, userInfo);
                string         queryString    = string.Empty;
                if (processedVideo.result == Result.Success)
                {
                    queryString += "?new=true&";
                    queryString += "path=" + processedVideo.networkAccessLocation + "&";
                    queryString += "name=" + processedVideo.videoName + "&";
                    queryString += "duration=" + processedVideo.videoDuration + "&";
                    queryString += "framerate=" + processedVideo.frameRate + "&";
                    queryString += "startframe=" + processedVideo.startFrame + "&";
                    queryString += "endframe=" + processedVideo.endFrame + "&";
                    queryString += "videoresolution=" + processedVideo.videoHeight + "&";
                    queryString += "pid=" + processedVideo.processID;
                    if (Convert.ToInt32(lstPlayingSpeed.SelectedValue) > 0)
                    {
                        queryString += "&playspeed=" + lstPlayingSpeed.SelectedValue;
                    }
                    if (txtCustomPlayTime.Text != string.Empty)
                    {
                        queryString += "&timeposition=" + txtCustomPlayTime.Text;
                    }
                    Response.Redirect("Player.aspx" + queryString);
                }
                else
                {
                    Response.Redirect("Error.aspx?id=301&message=" + processedVideo.message);
                }
                #endregion Main process


                #endregion New processing
            }
            else if (mode == AccessMode.Other)
            {
                Server.Transfer("Error.aspx?id=96");
            }
        }