コード例 #1
0
        public FtpMediaStream(IngestMedia media, bool forWrite)
        {
            _media = media;
            if (media == null || media.Directory == null)
            {
                throw new ApplicationException();
            }
            Uri uri = new Uri(media.FullPath);

            _client             = new System.Net.FtpClient.FtpClient();
            _client.Credentials = ((IngestDirectory)media.Directory)._getNetworkCredential();
            _client.Host        = uri.Host;
            try
            {
                _client.Connect();
                if (forWrite)
                {
                    _ftpStream = _client.OpenWrite(uri.LocalPath);
                }
                else
                {
                    _ftpStream = _client.OpenRead(uri.LocalPath);
                }
            }
            catch
            {
                _client.Dispose();
                throw;
            }
        }
コード例 #2
0
 // parse files from BMD's MediaExpress
 private void _scanXML(string xmlFileName)
 {
     foreach (Media fd in FindMediaList(f => (f is IngestMedia) && (f as IngestMedia).XmlFile == xmlFileName))
     {
         ((IngestMedia)fd).XmlFile = string.Empty;
     }
     try
     {
         XmlDocument doc = new XmlDocument();
         doc.Load(xmlFileName);
         try
         {
             XmlNodeList clips = doc.SelectNodes(@"/xmeml/clip|/xmeml/bin/children/clip");
             foreach (XmlNode clip in clips)
             {
                 string      fileName = Path.GetFileName((new Uri(Uri.UnescapeDataString(clip.SelectSingleNode(@"file/pathurl").InnerText))).LocalPath);
                 IngestMedia m        = (IngestMedia)FindMediaFirst(f => f.FileName == fileName);
                 if (m != null)
                 {
                     m.TcStart      = clip.SelectSingleNode(@"file/timecode/string").InnerText.SMPTETimecodeToTimeSpan(new RationalNumber(int.Parse(clip.SelectSingleNode(@"rate/timebase").InnerText), 1));
                     m.TcPlay       = m.TcStart;
                     m.Duration     = Int64.Parse(clip.SelectSingleNode(@"duration").InnerText).SMPTEFramesToTimeSpan(new RationalNumber(int.Parse(clip.SelectSingleNode(@"rate/timebase").InnerText), 1));
                     m.DurationPlay = m.Duration;
                     m.XmlFile      = xmlFileName;
                 }
             }
         }
         catch (NullReferenceException) { }
         catch (ArgumentNullException) { }
     }
     catch (Exception) { }
 }
コード例 #3
0
        public IngestMedia FindMedia(string clipName)
        {
            string      clipNameLowered = clipName.ToLower();
            IngestMedia result          = (IngestMedia)FindMediaFirst(f => Path.GetFileNameWithoutExtension(Path.GetFileName(f.FileName)).ToLower() == clipNameLowered);

            if (result == null & IsWAN)
            {
                string[] files = Directory.GetFiles(this.Folder, string.Format("{0}.*", clipName));
                if (files.Length > 0)
                {
                    string fileName = files[0];
                    result           = (IngestMedia)this.CreateMedia(fileName);
                    result.MediaName = Path.GetFileNameWithoutExtension(fileName);
                }
            }
            return(result);
        }
コード例 #4
0
 public FtpMediaStream(IngestMedia media)
 {
     _media = media;
     if (media == null || media.Directory == null)
         throw new ApplicationException();
     Uri uri = new Uri(media.FullPath);
     _client = new System.Net.FtpClient.FtpClient();
     _client.Credentials = media.Directory.NetworkCredential;
     _client.Host = uri.Host;
     try
     {
         _client.Connect();
         _ftpStream = _client.OpenRead(uri.LocalPath);
     }
     catch
     {
         _client.Dispose();
     }
 }
コード例 #5
0
 private bool _do(Media inputMedia)
 {
     _progressDuration = SourceMedia.Duration;
     _addOutputMessage("Refreshing XDCAM content");
     DestDirectory.Refresh();
     bool result = false;
     var existingFiles = DestDirectory.Files.Where(f => f.FileName.StartsWith("C", true, System.Globalization.CultureInfo.InvariantCulture));
     int maxFile = existingFiles.Count() == 0 ? 1 : existingFiles.Max(m => int.Parse(m.FileName.Substring(1, 4))) + 1;
     DestMedia = new IngestMedia() {MediaName = string.Format("C{0:D4}", maxFile), FileName = string.Format("C{0:D4}.MXF", maxFile), Folder = "Clip", MediaStatus = TMediaStatus.Copying, Directory = DestDirectory};
     if (DestDirectory.AccessType == TDirectoryAccessType.FTP)
     {
         using (TempMedia localDestMedia = FileManager.TempDirectory.Get(inputMedia, ".MXF"))
         {
             DestMedia.PropertyChanged += DestMedia_PropertyChanged;
             try
             {
                 result = _encode(inputMedia.FullPath, localDestMedia.FullPath);
                 if (result)
                 {
                     _progressFileSize = (UInt64)(new FileInfo(localDestMedia.FullPath)).Length;
                     _addOutputMessage(string.Format("Transfering file to device as {0}", DestMedia.FileName));
                     result = localDestMedia.CopyMediaTo(DestMedia, ref _aborted);
                 }
             }
             finally
             {
                 DestMedia.PropertyChanged -= DestMedia_PropertyChanged;
             }
         }
     }
     else
         result = _encode(inputMedia.FullPath, DestMedia.FullPath);
     if (result)
         DestMedia.MediaStatus = result ? TMediaStatus.Available : TMediaStatus.CopyError;
     if (result) OperationStatus = FileOperationStatus.Finished;
     return result;
 }