Example #1
0
        /// <summary>
        /// Open all files associated with the ISM.
        /// </summary>
        /// <param name="inPath">path name to ISM file without extension</param>
        public override void Open(string inPath, bool withCaching)
        {
            _mainFolderPath = Path.GetDirectoryName(inPath);
            _ismFile        = new ISMFile(_mainFolderPath, Path.GetFileNameWithoutExtension(inPath));
            foreach (ISMElement element in _ismFile.ISMElements)
            {
                GenericMediaTrack ismTrack = null;
                if (element.FragmentType == FragmentType.Video)
                {
                    ismTrack = new ISMVideoTrack(new ISMVTrackFormat(_mainFolderPath, element.Source, element), this);
                }
                else if (element.FragmentType == FragmentType.Audio)
                {
                    ismTrack = new ISMAudioTrack(new ISMVTrackFormat(_mainFolderPath, element.Source, element), this);
                }
                MediaTracks.Add(ismTrack);

                // choose longest track duration to be stream duration
                if (DurationIn100NanoSecs < ismTrack.TrackDurationIn100NanoSecs)
                {
                    DurationIn100NanoSecs = ismTrack.TrackDurationIn100NanoSecs;
                }
            }

            CachingEnabled = withCaching;
        }
Example #2
0
        public override void WriteSamples(IEnumerable <Slice> slices, CodecTypes codecType)
        {
            GenericMediaTrack track  = (GenericMediaTrack)this[codecType, 0];
            ISMVTrackFormat   format = (ISMVTrackFormat)track.TrackFormat;

            format.CurrentFragment.Write(m_writer);
            format.CurrentFragment.CheckFilePosition(m_writer);
            foreach (Slice sample in slices)
            {
                m_writer.Write(sample.SliceBytes, 0, sample.SliceBytes.Length);
            }
            format.CurrentFragment = null; // release
        }
        public override void Initialize(GenericMediaTrack cachedTrack)
        {
            base.Initialize(cachedTrack);

              track.TrackFormat.FetchNextBatch -= base.GetMoreBoxes;
              track.TrackFormat.FetchNextBatch += new LazyRead(TrackFormat_FetchNextBatch); // replace

              // put initial blocks in dictionary
              for (int i = 0; i < CacheBufCount; i++)
              {
            if (cache[i].SampleStreamLocations.Count > 0)
              AddToDictionary(cache[i]);
              }
        }
Example #4
0
        protected void CreateTracks <T1, T0, T2>() where T1 : GenericAudioTrack, new() where T0 : GenericVideoTrack, new() where T2 : MP4TrackFormat, new()
        {
            // boolean for calling event MediaTrackLogicalBreak only once
            bool breakCalled       = false;
            GenericMediaTrack trak = null;
            T2 trackFormat;

            foreach (TrackBox trackb in mmb.TrackBoxes)
            {
                trackFormat          = new T2();
                trackFormat.TrackBox = trackb;
                switch (trackb.PayloadType)
                {
                case "samr": // 3gpp audio
                case "wma ":
                case "mp4a":
                    trak          = new T1();
                    Hints.object1 = trackb.EdtsBox;
                    break;

                case "mp4v": // 3gpp video
                case "vc-1":
                case "avc1":
                    trak = new T0();
                    IVideoTrack    vt        = trak as IVideoTrack;
                    MP4TrackFormat mp4format = trackFormat as MP4TrackFormat;
                    vt.IsAnamorphic = mp4format.IsAnamorphic;
                    Hints.object2   = trackb.EdtsBox;
                    break;

                case "mp4s":
                    break; // ignore - in the case of vc-1 and wma, these are processed in ISMVStreamReader

                default:
                    throw new Exception(string.Format("Unknown track type: {0}", trackb.PayloadType));
                }
                if (trak != null)
                {
                    trak.TrackFormat  = trackFormat;
                    trak.ParentStream = this;
                    AddTrack(trak);

                    if (!breakCalled)
                    {
                        TriggerLogicalBreak(trak);
                        breakCalled = true;
                    }
                }
            }
        }
        public override void Initialize(GenericMediaTrack cachedTrack)
        {
            base.Initialize(cachedTrack);

            track.TrackFormat.FetchNextBatch -= base.GetMoreBoxes;
            track.TrackFormat.FetchNextBatch += new LazyRead(TrackFormat_FetchNextBatch); // replace

            // put initial blocks in dictionary
            for (int i = 0; i < CacheBufCount; i++)
            {
                if (cache[i].SampleStreamLocations.Count > 0)
                {
                    AddToDictionary(cache[i]);
                }
            }
        }
Example #6
0
        public virtual void Initialize(GenericMediaTrack cachedTrack)
        {
            track = cachedTrack;
              format = track.TrackFormat;
              stream = track.ParentStream;

              if (stream.IsForReading)
              {
            track.BlockWithSlice += new NextBlock(track_BlockWithSlice);
            track.TrackFormat.FetchNextBatch += new LazyRead(GetMoreBoxes);

            if ((writeCache == 0) && (readCache == 0))
              PrepareSampleInfo(0UL); // fill up the cache with first four blocks
              }
              else
              {
            track.PrepareMediaHeaders += new SlicePutRequest(track_PrepareMediaHeaders);
              }
        }
Example #7
0
 public void PrepareSampleWriting(GenericMediaTrack sourceTrack, ref ulong currMdatOffset)
 {
     base.PrepareSampleWriting(sourceTrack, ref currMdatOffset);
 }