Ejemplo n.º 1
0
 public void Browse(CpMediaServer server, System.String ObjectID, OpenSource.UPnP.AV.CpContentDirectory.Enum_A_ARG_TYPE_BrowseFlag BrowseFlag, System.String Filter, System.UInt32 StartingIndex, System.UInt32 RequestedCount, System.String SortCriteria, object _Tag, Delegate_OnBrowseDone _Callback)
 {
     _RequestState state = new _RequestState();
     state.Callback = _Callback;
     state.Tag = _Tag;
     state.Server = server;
     server.ContentDirectory.Browse(ObjectID, BrowseFlag, Filter, StartingIndex, RequestedCount, SortCriteria, state, new OpenSource.UPnP.AV.CpContentDirectory.Delegate_OnResult_Browse(_OnBrowseDone));
 }
        /// <summary>
        /// Allows a programmer to query the MediaServer through the Browse action.
        /// </summary>
        /// <param name="ObjectID"></param>
        /// <param name="BrowseFlag"></param>
        /// <param name="Filter"></param>
        /// <param name="StartingIndex"></param>
        /// <param name="RequestedCount"></param>
        /// <param name="SortCriteria"></param>
        /// <param name="_Tag"></param>
        /// <param name="callback">Returns output args and error info.</param>
        public void RequestBrowse(System.String ObjectID, OpenSource.UPnP.AV.CpContentDirectory.Enum_A_ARG_TYPE_BrowseFlag BrowseFlag, System.String Filter, System.UInt32 StartingIndex, System.UInt32 RequestedCount, System.String SortCriteria, object _Tag, Delegate_OnBrowseDone2 callback)
        {
            _RequestState state = new _RequestState();

            state.Callback_Browse2 = callback;
            state.Tag = _Tag;
            this.ContentDirectory.Browse(ObjectID, BrowseFlag, Filter, StartingIndex, RequestedCount, SortCriteria, state, new OpenSource.UPnP.AV.CpContentDirectory.Delegate_OnResult_Browse(OnBrowseDone));
        }
Ejemplo n.º 3
0
        public void Browse(CpMediaServer server, System.String ObjectID, Intel.UPNP.AV.CpContentDirectory.Enum_A_ARG_TYPE_BrowseFlag BrowseFlag, System.String Filter, System.UInt32 StartingIndex, System.UInt32 RequestedCount, System.String SortCriteria, object _Tag, Delegate_OnBrowseDone _Callback)
        {
            _RequestState state = new _RequestState();

            state.Callback = _Callback;
            state.Tag      = _Tag;
            state.Server   = server;
            server.ContentDirectory.Browse(ObjectID, BrowseFlag, Filter, StartingIndex, RequestedCount, SortCriteria, state, new Intel.UPNP.AV.CpContentDirectory.Delegate_OnResult_Browse(_OnBrowseDone));
        }
        /// <summary>
        /// Processes the results of Browse requests.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="ObjectID"></param>
        /// <param name="BrowseFlag"></param>
        /// <param name="Filter"></param>
        /// <param name="StartingIndex"></param>
        /// <param name="RequestedCount"></param>
        /// <param name="SortCriteria"></param>
        /// <param name="Result"></param>
        /// <param name="NumberReturned"></param>
        /// <param name="TotalMatches"></param>
        /// <param name="UpdateID"></param>
        /// <param name="e"></param>
        /// <param name="_Tag"></param>
        private void OnBrowseDone(CpContentDirectory sender, System.String ObjectID, OpenSource.UPnP.AV.CpContentDirectory.Enum_A_ARG_TYPE_BrowseFlag BrowseFlag, System.String Filter, System.UInt32 StartingIndex, System.UInt32 RequestedCount, System.String SortCriteria, System.String Result, System.UInt32 NumberReturned, System.UInt32 TotalMatches, System.UInt32 UpdateID, UPnPInvokeException e, object _Tag)
        {
            _RequestState state = (_RequestState)_Tag;

            if (e != null)
            {
                if (state.Callback_Browse1 != null)
                {
                    state.Callback_Browse1(this, ObjectID, BrowseFlag, Filter, StartingIndex, RequestedCount, SortCriteria, e, null, state.Tag, null, NumberReturned, TotalMatches, UpdateID);
                }
                else if (state.Callback_Browse2 != null)
                {
                    state.Callback_Browse2(this, e, null, state.Tag, null, NumberReturned, TotalMatches, UpdateID);
                }
            }
            else
            {
                ArrayList al = null;
                try
                {
                    al = CpMediaBuilder.BuildMediaBranches(Result);
                }
                catch (Exception parseError)
                {
                    if (state.Callback_Browse1 != null)
                    {
                        state.Callback_Browse1(this, ObjectID, BrowseFlag, Filter, StartingIndex, RequestedCount, SortCriteria, e, parseError, state.Tag, null, NumberReturned, TotalMatches, UpdateID);
                    }
                    else if (state.Callback_Browse2 != null)
                    {
                        state.Callback_Browse2(this, e, parseError, state.Tag, null, NumberReturned, TotalMatches, UpdateID);
                    }
                    al = null;
                }

                if (al != null)
                {
                    if (state.Callback_Browse1 != null)
                    {
                        state.Callback_Browse1(this, ObjectID, BrowseFlag, Filter, StartingIndex, RequestedCount, SortCriteria, e, null, state.Tag, (IUPnPMedia[])al.ToArray(typeof(IUPnPMedia)), NumberReturned, TotalMatches, UpdateID);
                    }
                    else if (state.Callback_Browse2 != null)
                    {
                        state.Callback_Browse2(this, e, null, state.Tag, (IUPnPMedia[])al.ToArray(typeof(IUPnPMedia)), NumberReturned, TotalMatches, UpdateID);
                    }
                }
            }
        }