All pastes #434699 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-04-11 15:35 UTC
rendered paste body
			try
			{
				Logger.Debug("Requesting the Contact handle");
				string[] names = {"sip:500@ekiga.net"};
				uint[] handles = tlpConnection.RequestHandles (HandleType.Contact, names);
				tlpConnection.HoldHandles (HandleType.Contact, handles);
				string[] memberNames = tlpConnection.InspectHandles (HandleType.Contact, handles);
				
				if(memberNames.Length < 1)
					Logger.Debug("The memberName was not returned!");
				else
					Logger.Debug("The member Name is: {0}", memberNames[0]);
				
//				ObjectPath op = tlpConnection.RequestChannel (ChannelType.ContactList, HandleType.List, handles[0], true);
//				IChannelGroup cl = 
//					Bus.Session.GetObject<IChannelGroup> (account.TelepathyBusName, op);
				

				if(handles.Length != 1)
				{
					Logger.Fatal("Error: requested a handle and got: {0}", handles.Length);
					return false;
				}
				Logger.Debug("Got the handle");


				Logger.Debug("Setting up Media Channel");
				mcObjectPath = 
					tlpConnection.RequestChannel (
						org.freedesktop.Telepathy.ChannelType.StreamedMedia, 
						HandleType.Contact,
						handles[0],
						true);
				Logger.Debug("Have the Media Channel Object Path");
				mediaChannel = 
					Bus.Session.GetObject<IChannelStreamedMedia> (busName, mcObjectPath);
				Logger.Debug("Have the Media Channel, what to do?");
								
		       //initialize media channel
		       channel_handler = Bus.Session.GetObject<IChannelHandler> ("org.freedesktop.Telepathy.StreamEngine",
		           new ObjectPath ("/org/freedesktop/Telepathy/StreamEngine"));
		       
		       if (channel_handler != null) 
		       {
		       	Logger.Debug("Have the channelHandler... telling it to handle the channel");
		       	channel_handler.HandleChannel ( connectionInfo.BusName, connectionInfo.ObjectPath,
		                                           mediaChannel.ChannelType, mcObjectPath,
		                                           0, 0);
		       }
		       else
		       	Logger.Debug("Didn't get a channel handler");
		       
		       Logger.Debug ("Attempting to add members...");
		       mediaChannel.AddMembers (handles, String.Empty);
		       Logger.Debug ("AddMembers called successfully");

	       
		       StreamInfo[] lst = ((IChannelStreamedMedia) mediaChannel).ListStreams();

				Logger.Debug("StreamInfo List Length: {0}", lst.Length);
				
		       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);
		       				
//		           StreamObject stream = CreateStream (info);
//		           hash_stream.Add (stream.Id, stream);
		       }
		       
		       mediaChannel.StreamAdded += OnStreamAdded;
		       mediaChannel.StreamDirectionChanged += OnStreamDirectionChanged;
		       mediaChannel.StreamError += OnStreamError;
		       mediaChannel.StreamRemoved += OnStreamRemoved;
		       mediaChannel.StreamStateChanged += OnStreamStateChanged;

//		       Logger.Debug("Sleeping 'cause we don't know what else to do...");
//		       System.Threading.Thread.Sleep(4000);	


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

		        Logger.Debug("have the stream engine");

			    stream_engine.AddPreviewWindow(previewWindowID);
				stream_engine.Receiving += OnStreamEngineReceiving;
				
				uint[] stream_type = new uint[2];
				
				stream_type[0] = (uint) org.freedesktop.Telepathy.StreamType.Video;
				stream_type[1] = (uint) org.freedesktop.Telepathy.StreamType.Audio;

				System.Threading.Thread.Sleep(4000);
				Logger.Debug("Requesting streams from media channel");
				
				StreamInfo[] infos = mediaChannel.RequestStreams (handles[0], stream_type);
				

				Logger.Debug("Number of Streams Received: {0}", infos.Length);
				
				foreach (StreamInfo info in infos) {
					Logger.Debug("Stream Info: Type: {0}, Id: {1}, State: {2}, Direction: {3}, ContactHandle: {4}", info.Type, info.Id, info.State, info.Direction, info.ContactHandle);
				}
			}
			catch(Exception e)
			{
				Logger.Debug(e.Message);
				Logger.Debug(e.StackTrace);
			
			}