Add feature to call.exe to send <bandwidth> in accept message, and fix the xmlns of <bandwidth>.

git-svn-id: http://libjingle.googlecode.com/svn/trunk@42 dd674b97-3498-5ee5-1854-bdd07cd0ff33
diff --git a/talk/examples/call/callclient.cc b/talk/examples/call/callclient.cc
index 92fcea3..eb761d1 100644
--- a/talk/examples/call/callclient.cc
+++ b/talk/examples/call/callclient.cc
@@ -117,7 +117,7 @@
 const char* RECEIVE_COMMANDS =
 "Available commands:\n"
 "\n"
-"  accept  Accepts the incoming call and switches to it.\n"
+"  accept [bw] Accepts the incoming call and switches to it.\n"
 "  reject  Rejects the incoming call and stays with the current call.\n"
 "  quit    Quits the application.\n"
 "";
@@ -167,7 +167,9 @@
     Quit();
   } else if (call_ && incoming_call_) {
     if (command == "accept") {
-      Accept();
+      cricket::CallOptions options;
+      options.video_bandwidth = GetInt(words, 1, cricket::kAutoBandwidth);
+      Accept(options);
     } else if (command == "reject") {
       Reject();
     } else {
@@ -211,12 +213,10 @@
       MakeCallTo(to, cricket::CallOptions());
     } else if (command == "vcall") {
       std::string to = GetWord(words, 1, "");
-      int bandwidth = GetInt(words, 2, -1);
+      int bandwidth = GetInt(words, 2, cricket::kAutoBandwidth);
       cricket::CallOptions options;
       options.is_video = true;
-      if (bandwidth > 0) {
-        options.video_bandwidth = bandwidth;
-      }
+      options.video_bandwidth = bandwidth;
       MakeCallTo(to, options);
     } else if (command == "join") {
       JoinMuc(GetWord(words, 1, ""));
@@ -413,8 +413,9 @@
     call_ = call;
     session_ = session;
     incoming_call_ = true;
+    cricket::CallOptions options;
     if (auto_accept_) {
-      Accept();
+      Accept(options);
     }
   } else if (state == cricket::Session::STATE_SENTINITIATE) {
     console_->Print("calling...");
@@ -653,10 +654,10 @@
   }
 }
 
-void CallClient::Accept() {
+void CallClient::Accept(const cricket::CallOptions& options) {
   ASSERT(call_ && incoming_call_);
   ASSERT(call_->sessions().size() == 1);
-  call_->AcceptSession(call_->sessions()[0]);
+  call_->AcceptSession(call_->sessions()[0], options);
   media_client_->SetFocus(call_);
   if (call_->video()) {
     call_->SetLocalRenderer(local_renderer_);
diff --git a/talk/examples/call/callclient.h b/talk/examples/call/callclient.h
index bdae6dc..a5686b4 100644
--- a/talk/examples/call/callclient.h
+++ b/talk/examples/call/callclient.h
@@ -152,7 +152,7 @@
   void MakeCallTo(const std::string& name, const cricket::CallOptions& options);
   void PlaceCall(const buzz::Jid& jid, const cricket::CallOptions& options);
   void CallVoicemail(const std::string& name);
-  void Accept();
+  void Accept(const cricket::CallOptions& options);
   void Reject();
   void Quit();
 
diff --git a/talk/p2p/base/constants.cc b/talk/p2p/base/constants.cc
index a0c4ba4..1becb39 100644
--- a/talk/p2p/base/constants.cc
+++ b/talk/p2p/base/constants.cc
@@ -99,6 +99,8 @@
     true, NS_JINGLE_RTP, LN_DESCRIPTION);
 const buzz::QName QN_JINGLE_RTP_PAYLOADTYPE(
     true, NS_JINGLE_RTP, LN_PAYLOADTYPE);
+const buzz::QName QN_JINGLE_RTP_BANDWIDTH(
+    true, NS_JINGLE_RTP, LN_BANDWIDTH);
 const buzz::QName QN_PARAMETER(true, NS_JINGLE_RTP, "parameter");
 
 const std::string NS_GINGLE_AUDIO("http://www.google.com/session/phone");
@@ -113,6 +115,8 @@
 const buzz::QName QN_GINGLE_VIDEO_PAYLOADTYPE(
     true, NS_GINGLE_VIDEO, LN_PAYLOADTYPE);
 const buzz::QName QN_GINGLE_VIDEO_SRCID(true, NS_GINGLE_VIDEO, "src-id");
+const buzz::QName QN_GINGLE_VIDEO_BANDWIDTH(
+    true, NS_GINGLE_VIDEO, LN_BANDWIDTH);
 
 // Crypto support.
 const buzz::QName QN_ENCRYPTION(true, NS_JINGLE_RTP, "encryption");
diff --git a/talk/p2p/base/constants.h b/talk/p2p/base/constants.h
index 8355210..9f93cbc 100644
--- a/talk/p2p/base/constants.h
+++ b/talk/p2p/base/constants.h
@@ -119,6 +119,7 @@
 extern const std::string NS_JINGLE_RTP;
 extern const buzz::QName QN_JINGLE_RTP_CONTENT;
 extern const buzz::QName QN_JINGLE_RTP_PAYLOADTYPE;
+extern const buzz::QName QN_JINGLE_RTP_BANDWIDTH;
 
 extern const std::string NS_GINGLE_AUDIO;
 extern const buzz::QName QN_GINGLE_AUDIO_CONTENT;
diff --git a/talk/session/phone/call.cc b/talk/session/phone/call.cc
index d72f913..fa4d33d 100644
--- a/talk/session/phone/call.cc
+++ b/talk/session/phone/call.cc
@@ -91,13 +91,14 @@
   SignalSessionState(this, session, Session::STATE_RECEIVEDINITIATE);
 }
 
-void Call::AcceptSession(BaseSession *session) {
+void Call::AcceptSession(BaseSession* session,
+                         const cricket::CallOptions& options) {
   std::vector<Session *>::iterator it;
   it = std::find(sessions_.begin(), sessions_.end(), session);
   ASSERT(it != sessions_.end());
   if (it != sessions_.end()) {
     session->Accept(
-        session_client_->CreateAnswer(session->remote_description()));
+        session_client_->CreateAnswer(session->remote_description(), options));
   }
 }
 
diff --git a/talk/session/phone/call.h b/talk/session/phone/call.h
index f3fcbf1..8e9bcdc 100644
--- a/talk/session/phone/call.h
+++ b/talk/session/phone/call.h
@@ -50,7 +50,7 @@
   ~Call();
 
   Session *InitiateSession(const buzz::Jid &jid, const CallOptions& options);
-  void AcceptSession(BaseSession *session);
+  void AcceptSession(BaseSession *session, const CallOptions& options);
   void RejectSession(BaseSession *session);
   void TerminateSession(BaseSession *session);
   void Terminate();
diff --git a/talk/session/phone/mediasessionclient.cc b/talk/session/phone/mediasessionclient.cc
index 645524a..f16b531 100644
--- a/talk/session/phone/mediasessionclient.cc
+++ b/talk/session/phone/mediasessionclient.cc
@@ -251,7 +251,7 @@
 }
 
 SessionDescription* MediaSessionClient::CreateAnswer(
-    const SessionDescription* offer) {
+    const SessionDescription* offer, const CallOptions& options) {
   // The answer contains the intersection of the codecs in the offer with the
   // codecs we support, ordered by our local preference. As indicated by
   // XEP-0167, we retain the same payload ids from the offer in the answer.
@@ -312,6 +312,7 @@
       }
     }
 
+    video_accept->set_bandwidth(options.video_bandwidth);
     video_accept->SortCodecs();
 
     if (secure() != SEC_DISABLED) {
@@ -360,7 +361,7 @@
 
     // If our accept would have no codecs, then we must reject this call.
     const SessionDescription* offer = session->remote_description();
-    const SessionDescription* accept = CreateAnswer(offer);
+    const SessionDescription* accept = CreateAnswer(offer, CallOptions());
     const ContentInfo* audio_content = GetFirstAudioContent(accept);
     const AudioContentDescription* audio_accept = (!audio_content) ? NULL :
         static_cast<const AudioContentDescription*>(audio_content->description);
@@ -790,10 +791,9 @@
   return elem;
 }
 
-buzz::XmlElement* CreateBandwidthElem(int bps) {
+buzz::XmlElement* CreateBandwidthElem(const buzz::QName& name, int bps) {
   int kbps = bps / 1000;
-  buzz::XmlElement* elem = new buzz::XmlElement(
-      buzz::QName(true, "", LN_BANDWIDTH), true);
+  buzz::XmlElement* elem = new buzz::XmlElement(name);
   elem->AddAttr(buzz::QN_TYPE, "AS");
   SetXmlBody(elem, kbps);
   return elem;
@@ -881,7 +881,8 @@
         QN_GINGLE_VIDEO_SRCID, video->ssrc()));
   }
   if (video->bandwidth() != kAutoBandwidth) {
-    elem->AddElement(CreateBandwidthElem(video->bandwidth()));
+    elem->AddElement(CreateBandwidthElem(QN_GINGLE_VIDEO_BANDWIDTH,
+                                         video->bandwidth()));
   }
 
   const CryptoParamsVec& cryptos = video->cryptos();
@@ -977,7 +978,8 @@
   }
 
   if (video->bandwidth() != kAutoBandwidth) {
-    elem->AddElement(CreateBandwidthElem(video->bandwidth()));
+    elem->AddElement(CreateBandwidthElem(QN_JINGLE_RTP_BANDWIDTH,
+                                         video->bandwidth()));
   }
 
   // TODO: Figure out how to integrate SSRC into Jingle.
diff --git a/talk/session/phone/mediasessionclient.h b/talk/session/phone/mediasessionclient.h
index 8f157ee..a74fe3e 100644
--- a/talk/session/phone/mediasessionclient.h
+++ b/talk/session/phone/mediasessionclient.h
@@ -131,7 +131,8 @@
   sigslot::repeater0<> SignalDevicesChange;
 
   SessionDescription* CreateOffer(const CallOptions& options);
-  SessionDescription* CreateAnswer(const SessionDescription* offer);
+  SessionDescription* CreateAnswer(const SessionDescription* offer,
+                                   const CallOptions& options);
 
   SecureMediaPolicy secure() const { return secure_; }
   void set_secure(SecureMediaPolicy s) { secure_ = s; }
diff --git a/talk/site_scons/talk.py b/talk/site_scons/talk.py
index fda5417..b9e93ef 100644
--- a/talk/site_scons/talk.py
+++ b/talk/site_scons/talk.py
@@ -385,9 +385,12 @@
 
 # Linux can build both 32 and 64 bit on 64 bit host, but 32 bit host can
 # only build 32 bit.  For 32 bit debian installer a 32 bit host is required.
-
+# ChromeOS (linux) ebuild don't support 64 bit and requires 32 bit build only
+# for now.
+# TODO: Detect ChromeOS chroot board for ChromeOS x64 build.
 def Allow64BitCompile(env):
-  return env.Bit('linux') and env.Bit('platform_arch_64bit')
+  return (env.Bit('linux') and env.Bit('platform_arch_64bit') and
+          not env.Bit('linux_chromeos'))
 
 def MergeSettingsFromLibraryDependencies(env, params):
   if params.has_key('libs'):