示例#1
0
        private void TestAddGroup()
        {
            int hr;

            hr = m_pTimeline.AddGroup((IAMTimelineObj)m_pVideoGroup);
            DESError.ThrowExceptionForHR(hr);
        }
        private void InitVideo()
        {
            int hr;

            IAMTimelineGroup pVideoGroup = (IAMTimelineGroup)m_pVideoGroupObj;

            // all we set is the major type. The group will automatically use other defaults
            AMMediaType VideoGroupType = new AMMediaType();

            VideoGroupType.majorType = MediaType.Video;

            hr = pVideoGroup.SetMediaType(VideoGroupType);
            DESError.ThrowExceptionForHR(hr);
            DsUtils.FreeAMMediaType(VideoGroupType);

            // add the video group to the timeline
            hr = m_pTimeline.AddGroup(m_pVideoGroupObj);
            DESError.ThrowExceptionForHR(hr);

            IAMTimelineObj pTrack1Obj;

            hr = m_pTimeline.CreateEmptyNode(out pTrack1Obj, TimelineMajorType.Track);
            DESError.ThrowExceptionForHR(hr);

            // tell the composition about the track
            IAMTimelineComp pRootComp = (IAMTimelineComp)m_pVideoGroupObj;

            hr = pRootComp.VTrackInsBefore(pTrack1Obj, -1);
            DESError.ThrowExceptionForHR(hr);

            m_VideoTrack = (IAMTimelineTrack)pTrack1Obj;
        }
示例#3
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="mType">Media type of the new group</param>
        /// <param name="pTimeline">Timeline to use for the group</param>
        /// <param name="fps">FPS for the group</param>
        public MediaGroup(AMMediaType mType, IAMTimeline pTimeline, double fps)
        {
            int            hr;
            IAMTimelineObj pGroupObj;

            m_Length    = 0;
            m_Files     = new ArrayList();
            m_FPS       = fps;
            m_pTimeline = pTimeline;

            // make the root group/composition
            hr = m_pTimeline.CreateEmptyNode(out pGroupObj, TimelineMajorType.Group);
            DESError.ThrowExceptionForHR(hr);

            try
            {
                m_pGroup = (IAMTimelineGroup)pGroupObj;

                // Set the media type we just created
                hr = m_pGroup.SetMediaType(mType);
                DESError.ThrowExceptionForHR(hr);
                DsUtils.FreeAMMediaType(mType);

                // add the video group to the timeline
                hr = m_pTimeline.AddGroup(pGroupObj);
                DESError.ThrowExceptionForHR(hr);
            }
            finally
            {
                //Marshal.ReleaseComObject(pGroupObj);
            }
            //Marshal.ReleaseComObject(pTrack1Obj);  // Released as m_VideoTrack in dispose
        }
示例#4
0
    /// <summary>
    /// Constructor
    /// </summary>
    /// <param name="mType">Media type of the new group</param>
    /// <param name="pTimeline">Timeline to use for the group</param>
    /// <param name="fps">FPS for the group</param>
    public MediaGroup(AMMediaType mType, IAMTimeline pTimeline, double fps)
    {
      int hr;
      IAMTimelineObj pGroupObj;

      m_Length = 0;
      m_Files = new ArrayList();
      m_FPS = fps;
      m_pTimeline = pTimeline;

      // make the root group/composition
      hr = m_pTimeline.CreateEmptyNode(out pGroupObj, TimelineMajorType.Group);
      DESError.ThrowExceptionForHR(hr);

      try
      {
        m_pGroup = (IAMTimelineGroup)pGroupObj;

        // Set the media type we just created
        hr = m_pGroup.SetMediaType(mType);
        DESError.ThrowExceptionForHR(hr);
        DsUtils.FreeAMMediaType(mType);

        // add the video group to the timeline
        hr = m_pTimeline.AddGroup(pGroupObj);
        DESError.ThrowExceptionForHR(hr);
      }
      finally
      {
        //Marshal.ReleaseComObject(pGroupObj);
      }
      //Marshal.ReleaseComObject(pTrack1Obj);  // Released as m_VideoTrack in dispose
    }
示例#5
0
        public DESGroup(AMMediaType mType, IAMTimeline pTimeline, VideoLayerCollection ds, int hWinWidth, int hWinHeight)
        {
            int              hr;
            IAMTimelineObj   pGroupObj;
            IAMTimelineGroup pGroup;

            m_Width     = hWinWidth;
            m_Height    = hWinHeight;
            m_Length    = 0;
            m_Files     = new List <MediaFile>();
            m_pTimeline = pTimeline;

            for (int i = 0; i < ds.Count; i++)
            {
                if (ds[i].EndTime > m_MaxLength)
                {
                    m_MaxLength = ds[i].EndTime;
                }
            }
            m_MaxLength = m_MaxLength == 0 ? ds.PlayLength : m_MaxLength;
            if (ds.PlayLength <= m_MaxLength)
            {
                m_RepeatNums = 1;
            }
            else
            {
                m_RepeatNums = ds.PlayLength / m_MaxLength + (ds.PlayLength % m_MaxLength == 0 ? 0 : 1);
            }

            // make the root group/composition
            hr = m_pTimeline.CreateEmptyNode(out pGroupObj, TimelineMajorType.Group);
            DESError.ThrowExceptionForHR(hr);


            try
            {
                pGroup = (IAMTimelineGroup)pGroupObj;
                // Set the media type we just created
                hr = pGroup.SetMediaType(mType);
                DESError.ThrowExceptionForHR(hr);
                DsUtils.FreeAMMediaType(mType);
                // add the video group to the timeline
                hr = m_pTimeline.AddGroup(pGroupObj);
                DESError.ThrowExceptionForHR(hr);
                List <Layer> ImageDS = ds.FindAll(ImageLayer);
                m_TrackArr = new IAMTimelineTrack[m_RepeatNums * ImageDS.Count + 2];
                m_CompArr  = new IAMTimelineComp[m_RepeatNums * ImageDS.Count + 2];
                AddCompAndTrack(ds, pGroup);
            }
            finally
            {
                Marshal.ReleaseComObject(pGroupObj);
            }
        }
示例#6
0
        /// <summary>
        /// Inserts a group into a timeline, and assigns it the supplied media type.
        /// Will free the media type upon completion.
        /// </summary>
        /// <param name="timeline"></param>
        /// <param name="mediaType"></param>
        /// <returns></returns>
        internal static IAMTimelineGroup InsertGroup(IAMTimeline timeline, AMMediaType mediaType, string name)
        {
            try
            {
                int hr = 0;

                IAMTimelineObj groupObj;

                // make the root group/composition
                hr = timeline.CreateEmptyNode(out groupObj, TimelineMajorType.Group);
                DESError.ThrowExceptionForHR(hr);

                if (!string.IsNullOrEmpty(name))
                {
                    hr = groupObj.SetUserName(name);
                    DESError.ThrowExceptionForHR(hr);
                }

                IAMTimelineGroup group = (IAMTimelineGroup)groupObj;

                // Set the media type we just created
                hr = group.SetMediaType(mediaType);
                DESError.ThrowExceptionForHR(hr);


                // add the group to the timeline
                hr = timeline.AddGroup(groupObj);
                DESError.ThrowExceptionForHR(hr);

                return(group);
            }
            finally
            {
                DsUtils.FreeAMMediaType(mediaType);
            }
        }