Example #1
0
        /// <summary>
        /// Method to start streaming the audio and 
        /// video channels
        /// </summary>
        public void StartAudioVideoStreams(uint previewWindowId, uint peerwindowId)
        {
            Logger.Debug ("StartAudioVideoStreams - called");

            if (mediaChannel == null) SetupMediaChannel ();
            if (mediaChannel == null)
                throw new ApplicationException ("Failed to get a media channel");

            this.peerWindowID = peerwindowId;
            this.previewWindowID = previewWindowId;

            IChannelHandler	channelHandler =
                Bus.Session.GetObject<IChannelHandler> (
                    "org.freedesktop.Telepathy.StreamEngine",
                    new ObjectPath ("/org/freedesktop/Telepathy/StreamEngine"));

            if (channelHandler == null)
                throw new ApplicationException ("Failed get a channel handler");

            Logger.Debug("Have the channelHandler... telling it to handle the channel");
            channelHandler.HandleChannel (
                account.BusName,
                account.BusPath,
                mediaChannel.ChannelType,
                mediaChannelObjectPath,
                0,
                0);

            StreamInfo[] lst = ((IChannelStreamedMedia) mediaChannel).ListStreams();
            Logger.Debug("StreamInfo List Length: {0}", lst.Length);

            uint tempStreamId;
               	foreach (StreamInfo info in lst) {
               		Logger.Debug("Stream Info: Id:{0}, Type:{1}, ContactHandle:{2}, Direction: {3}",
                           info.Id, info.Type, info.ContactHandle, info.Direction);

                // Save the type of the stream so we can reference it later
                SaveStream (info.Type, info.Id);
            }

            streamEngine =
                Bus.Session.GetObject<IStreamEngine> (
                    "org.freedesktop.Telepathy.StreamEngine",
               		new ObjectPath ("/org/freedesktop/Telepathy/StreamEngine"));

            Logger.Debug ("Adding Preview Window {0}", previewWindowId);
            streamEngine.AddPreviewWindow (previewWindowId);
            IndicateSystemMessage ("Video call started");

            /*
            if (this.videoStreams.Count > 0) {
                Logger.Debug("Adding Preview Window {0}", previewWindowId);
                streamEngine.AddPreviewWindow(previewWindowId);
                IndicateSystemMessage ("Video chat started");
            } else
                IndicateSystemMessage ("Audio chat started")
            */

            streamEngine.Receiving += OnStreamEngineReceiving;

            if (this.initiated == true) {
                uint[] streamtypes = new uint[2];
                streamtypes[0] = (uint) StreamType.Audio;
                streamtypes[1] = (uint) StreamType.Video;

                Logger.Debug("Requesting streams from media channel");
                uint[] handles = new uint [] {peerUser.ID};
                StreamInfo[] infos = mediaChannel.RequestStreams (handles[0], streamtypes);
            }
        }
Example #2
0
        /// <summary>
        /// Method to start streaming the audio and
        /// video channels
        /// </summary>
        public void StartAudioVideoStreams(uint previewWindowId, uint peerwindowId)
        {
            Logger.Debug("StartAudioVideoStreams - called");

            if (mediaChannel == null)
            {
                SetupMediaChannel();
            }
            if (mediaChannel == null)
            {
                throw new ApplicationException("Failed to get a media channel");
            }

            this.peerWindowID    = peerwindowId;
            this.previewWindowID = previewWindowId;

            IChannelHandler channelHandler =
                Bus.Session.GetObject <IChannelHandler> (
                    "org.freedesktop.Telepathy.StreamEngine",
                    new ObjectPath("/org/freedesktop/Telepathy/StreamEngine"));

            if (channelHandler == null)
            {
                throw new ApplicationException("Failed get a channel handler");
            }

            Logger.Debug("Have the channelHandler... telling it to handle the channel");
            channelHandler.HandleChannel(
                account.BusName,
                account.BusPath,
                mediaChannel.ChannelType,
                mediaChannelObjectPath,
                0,
                0);

            StreamInfo[] lst = ((IChannelStreamedMedia)mediaChannel).ListStreams();
            Logger.Debug("StreamInfo List Length: {0}", lst.Length);

            uint tempStreamId;

            foreach (StreamInfo info in lst)
            {
                Logger.Debug("Stream Info: Id:{0}, Type:{1}, ContactHandle:{2}, Direction: {3}",
                             info.Id, info.Type, info.ContactHandle, info.Direction);

                // Save the type of the stream so we can reference it later
                SaveStream(info.Type, info.Id);
            }

            streamEngine =
                Bus.Session.GetObject <IStreamEngine> (
                    "org.freedesktop.Telepathy.StreamEngine",
                    new ObjectPath("/org/freedesktop/Telepathy/StreamEngine"));

            Logger.Debug("Adding Preview Window {0}", previewWindowId);
            streamEngine.AddPreviewWindow(previewWindowId);
            IndicateSystemMessage("Video call started");

            /*
             * if (this.videoStreams.Count > 0) {
             *      Logger.Debug("Adding Preview Window {0}", previewWindowId);
             *  streamEngine.AddPreviewWindow(previewWindowId);
             *      IndicateSystemMessage ("Video chat started");
             * } else
             *      IndicateSystemMessage ("Audio chat started")
             */

            streamEngine.Receiving += OnStreamEngineReceiving;

            if (this.initiated == true)
            {
                uint[] streamtypes = new uint[2];
                streamtypes[0] = (uint)StreamType.Audio;
                streamtypes[1] = (uint)StreamType.Video;

                Logger.Debug("Requesting streams from media channel");
                uint[]       handles = new uint [] { peerUser.ID };
                StreamInfo[] infos   = mediaChannel.RequestStreams(handles[0], streamtypes);
            }
        }