Ivan Vučica avatar Ivan Vučica committed 8e93541

Added more output to see what's happening more easily. Added a cricket::ContentInfo to the cricket::SessionDescription. Made a few functions in the session class public, since they will apparently have to be called from outside (and are public in libjingle's cricket::Session). Copypasted the body for these functions.

Comments (0)

Files changed (1)

libjingle-p2ponly.cpp

 
 
     
-private:
 	virtual cricket::TransportChannel *CreateChannel(
                                              const std::string& content_name,
                                              const std::string& channel_name)
 	{
 		printf("%s: %s %s\n", __PRETTY_FUNCTION__, content_name.c_str(), channel_name.c_str());
+
+        /*
+         c/p:
+         
+        // We create the proxy "on demand" here because we need to support
+        // creating channels at any time, even before we send or receive
+        // initiate messages, which is before we create the transports.
+        TransportProxy* transproxy = GetOrCreateTransportProxy(content_name);
+        return transproxy->CreateChannel(channel_name, content_type_);
+         */
         
         return NULL;
 	}
                                           const std::string& channel_name)
 	{
 		printf("%s: %s %s\n", __PRETTY_FUNCTION__, content_name.c_str(), channel_name.c_str());
+        
+        /*
+         c/p:
+         
+        TransportProxy* transproxy = GetTransportProxy(content_name);
+        if (transproxy == NULL)
+            return NULL;
+        else
+            return transproxy->GetChannel(channel_name);
+         */
+        
+        
         return NULL;
 	}
 	virtual void DestroyChannel(
                         const std::string& channel_name)
 	{
 		printf("%s: %s %s\n", __PRETTY_FUNCTION__, content_name.c_str(), channel_name.c_str());
-	}
+        /*
+         c/p:
+         
+        TransportProxy* transproxy = GetTransportProxy(content_name);
+        ASSERT(transproxy != NULL);
+        transproxy->DestroyChannel(channel_name);
+
+        */
+    }
+    
+private:
     
 	virtual bool Accept(const cricket::SessionDescription* sdesc)
 	{
         // c/p
         for (cricket::TransportInfos::const_iterator tinfo = tinfos.begin();
              tinfo != tinfos.end(); ++tinfo) {
+            printf("(creating transport proxy: %s)\n", tinfo->content_name.c_str());
             if (tinfo->transport_type != transport_type_) {
                 error->SetText("No supported transport in offer.");
                 return false;
         // c/p
         for (cricket::TransportMap::iterator iter = transports_.begin(); iter != transports_.end(); ++iter) 
         {
+            printf("(connecting a channel)\n");
             iter->second->SpeculativelyConnectChannels();
         }
     }
         cricket::TransportInfos tinfos;
         for (cricket::ContentInfos::const_iterator content = contents.begin(); content != contents.end(); ++content) 
         {
+            printf("(adding a new transport info: %s)\n", content->name.c_str());
             tinfos.push_back(cricket::TransportInfo(content->name, transport_type_, cricket::Candidates()));
         }
         return tinfos;
 libjinglep2ponlySession *session = NULL;
 int main()
 {
+    printf(" ==> initializing a new network manager\n");
     networkManager = new talk_base::NetworkManager();
+    printf(" ==> creating an httpPortAllocator\n");
     httpPortAllocator = new cricket::HttpPortAllocator(networkManager, USER_AGENT);
     //p2pTransportChannel = new cricket::P2PTransportChannel("Kanal", "sadrzaj", p2pTransport, httpPortAllocator);
+    printf(" ==> creating our custom session manager\n");
     sessionManager = new libjinglep2ponlySessionManager(httpPortAllocator);
     
+    printf(" ==> creating a new session\n");
     session = sessionManager->CreateSession("Local Session Name", "test-type");
-    cricket::SessionDescription sessionDescription;
-    
+
+    printf(" ==> creating contentinfos to be able to initiate session\n");
+    cricket::ContentInfos contentInfos; // this is a std::vector<cricket::ContentInfo>
+    cricket::ContentDescription contentDescription; // we should actually inherit from this class to describe the content
+    contentInfos.push_back(cricket::ContentInfo("name", "type", &contentDescription));
+
+    printf(" ==> initiating our session\n");
+    cricket::SessionDescription sessionDescription(contentInfos);
     session->Initiate("destination", &sessionDescription);
+
+    printf(" ==> simulating an acceptance message\n");
     cricket::SessionMessage m;
     m.type = cricket::ACTION_SESSION_ACCEPT;
     session->OnIncomingMessage(m);
+
+    printf(" ==> running an infinite loop\n");
     while(1)
     {
     
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.