You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

852 lines
31 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. diff --git a/webrtc/examples/peerconnection/client/conductor.cc b/webrtc/examples/peerconnection/client/conductor.cc
  2. index 8a1b9a2..f9817c3 100644
  3. --- a/webrtc/examples/peerconnection/client/conductor.cc
  4. +++ b/webrtc/examples/peerconnection/client/conductor.cc
  5. @@ -18,10 +18,13 @@
  6. #include "webrtc/examples/peerconnection/client/defaults.h"
  7. #include "webrtc/media/engine/webrtcvideocapturerfactory.h"
  8. #include "webrtc/modules/video_capture/video_capture_factory.h"
  9. +#include "webrtc/modules/video_coding/codecs/h264/h264_encoder_impl.h"
  10. #include "webrtc/rtc_base/checks.h"
  11. #include "webrtc/rtc_base/json.h"
  12. #include "webrtc/rtc_base/logging.h"
  13. +#include "webrtc/examples/peerconnection/client/h264videocapturer.h"
  14. +
  15. // Names used for a IceCandidate JSON object.
  16. const char kCandidateSdpMidName[] = "sdpMid";
  17. const char kCandidateSdpMlineIndexName[] = "sdpMLineIndex";
  18. @@ -34,6 +37,14 @@ const char kSessionDescriptionSdpName[] = "sdp";
  19. #define DTLS_ON true
  20. #define DTLS_OFF false
  21. +void RemoveLine(std::string& source, const std::string& to_remove, int offset)
  22. +{
  23. + size_t nFPos = source.find(to_remove,offset);
  24. + size_t secondNL = source.find('\n', nFPos);
  25. + size_t firstNL = source.rfind('\n', nFPos);
  26. + source.erase(firstNL, secondNL - firstNL);
  27. +}
  28. +
  29. class DummySetSessionDescriptionObserver
  30. : public webrtc::SetSessionDescriptionObserver {
  31. public:
  32. @@ -127,7 +138,7 @@ bool Conductor::CreatePeerConnection(bool dtls) {
  33. constraints.AddOptional(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp,
  34. "false");
  35. }
  36. -
  37. + constraints.SetMandatoryReceiveVideo(false);
  38. peer_connection_ = peer_connection_factory_->CreatePeerConnection(
  39. config, &constraints, NULL, NULL, this);
  40. return peer_connection_.get() != NULL;
  41. @@ -233,6 +244,31 @@ void Conductor::OnMessageFromPeer(int peer_id, const std::string& message) {
  42. RTC_DCHECK(peer_id_ == peer_id || peer_id_ == -1);
  43. RTC_DCHECK(!message.empty());
  44. + Json::Reader reader;
  45. + Json::Value jmessage;
  46. + if (!reader.parse(message, jmessage)) {
  47. + LOG(WARNING) << "Received unknown message. " << message;
  48. + return;
  49. + }
  50. + std::string type;
  51. + std::string json_object;
  52. +
  53. + rtc::GetStringFromJsonObject(jmessage, kSessionDescriptionTypeName, &type);
  54. +
  55. + /********************* Messages that do not need any connection **************/
  56. + if (!type.empty()) {
  57. + if (type == "pleaseCallMe" ) {
  58. + LOG(INFO) << "Peer id: " << peer_id;
  59. + LOG(INFO) << "Peer id_: " << peer_id_;
  60. + //std::cout << "Please Call me";
  61. + ConnectToPeer(peer_id);
  62. + return;
  63. + }
  64. + }
  65. +
  66. +
  67. + /******************************************************************************/
  68. +
  69. if (!peer_connection_.get()) {
  70. RTC_DCHECK(peer_id_ == -1);
  71. peer_id_ = peer_id;
  72. @@ -249,16 +285,6 @@ void Conductor::OnMessageFromPeer(int peer_id, const std::string& message) {
  73. return;
  74. }
  75. - Json::Reader reader;
  76. - Json::Value jmessage;
  77. - if (!reader.parse(message, jmessage)) {
  78. - LOG(WARNING) << "Received unknown message. " << message;
  79. - return;
  80. - }
  81. - std::string type;
  82. - std::string json_object;
  83. -
  84. - rtc::GetStringFromJsonObject(jmessage, kSessionDescriptionTypeName, &type);
  85. if (!type.empty()) {
  86. if (type == "offer-loopback") {
  87. // This is a loopback call.
  88. @@ -336,10 +362,11 @@ void Conductor::OnServerConnectionFailure() {
  89. // MainWndCallback implementation.
  90. //
  91. -void Conductor::StartLogin(const std::string& server, int port) {
  92. +void Conductor::StartLogin(const std::string& server, int port, const std::string& video_url) {
  93. if (client_->is_connected())
  94. return;
  95. server_ = server;
  96. + video_url_ = video_url;
  97. client_->Connect(server, port, GetPeerName());
  98. }
  99. @@ -360,7 +387,10 @@ void Conductor::ConnectToPeer(int peer_id) {
  100. if (InitializePeerConnection()) {
  101. peer_id_ = peer_id;
  102. - peer_connection_->CreateOffer(this, NULL);
  103. + webrtc::FakeConstraints constraints;
  104. + constraints.SetMandatoryMaxFrameRate(60);
  105. + constraints.SetMandatoryReceiveVideo(false);
  106. + peer_connection_->CreateOffer(this, &constraints);
  107. } else {
  108. main_wnd_->MessageBox("Error", "Failed to initialize PeerConnection", true);
  109. }
  110. @@ -400,21 +430,29 @@ void Conductor::AddStreams() {
  111. if (active_streams_.find(kStreamLabel) != active_streams_.end())
  112. return; // Already added.
  113. +#if 0
  114. rtc::scoped_refptr<webrtc::AudioTrackInterface> audio_track(
  115. peer_connection_factory_->CreateAudioTrack(
  116. kAudioLabel, peer_connection_factory_->CreateAudioSource(NULL)));
  117. +#endif
  118. + webrtc::FakeConstraints constraints;
  119. + constraints.SetMandatoryMaxFrameRate(60);
  120. + constraints.SetMandatoryReceiveVideo(false);
  121. +
  122. + cricket::VideoCapturer* capturer = NULL;
  123. + capturer = new RawVideoCapturer(video_url_);
  124. rtc::scoped_refptr<webrtc::VideoTrackInterface> video_track(
  125. peer_connection_factory_->CreateVideoTrack(
  126. kVideoLabel,
  127. - peer_connection_factory_->CreateVideoSource(OpenVideoCaptureDevice(),
  128. + peer_connection_factory_->CreateVideoSource(/*OpenVideoCaptureDevice()*/capturer,
  129. NULL)));
  130. main_wnd_->StartLocalRenderer(video_track);
  131. rtc::scoped_refptr<webrtc::MediaStreamInterface> stream =
  132. peer_connection_factory_->CreateLocalMediaStream(kStreamLabel);
  133. - stream->AddTrack(audio_track);
  134. + //stream->AddTrack(audio_track);
  135. stream->AddTrack(video_track);
  136. if (!peer_connection_->AddStream(stream)) {
  137. LOG(LS_ERROR) << "Adding stream to PeerConnection failed";
  138. @@ -519,6 +557,18 @@ void Conductor::OnSuccess(webrtc::SessionDescriptionInterface* desc) {
  139. std::string sdp;
  140. desc->ToString(&sdp);
  141. +#if 0
  142. + while(sdp.find("nack",0)!=std::string::npos){
  143. + RemoveLine(sdp,"nack",0);
  144. + }
  145. + while(sdp.find("fir",0)!=std::string::npos){
  146. + RemoveLine(sdp,"fir",0);
  147. + }
  148. + while(sdp.find("remb",0)!=std::string::npos){
  149. + RemoveLine(sdp,"remb",0);
  150. + }
  151. +#endif
  152. +
  153. // For loopback test. To save some connecting delay.
  154. if (loopback_) {
  155. // Replace message type from "offer" to "answer"
  156. diff --git a/webrtc/examples/peerconnection/client/conductor.h b/webrtc/examples/peerconnection/client/conductor.h
  157. index 0041a9b..7e49201 100644
  158. --- a/webrtc/examples/peerconnection/client/conductor.h
  159. +++ b/webrtc/examples/peerconnection/client/conductor.h
  160. @@ -102,7 +102,7 @@ class Conductor
  161. // MainWndCallback implementation.
  162. //
  163. - void StartLogin(const std::string& server, int port) override;
  164. + void StartLogin(const std::string& server, int port, const std::string& video_url) override;
  165. void DisconnectFromServer() override;
  166. @@ -131,6 +131,7 @@ class Conductor
  167. std::map<std::string, rtc::scoped_refptr<webrtc::MediaStreamInterface> >
  168. active_streams_;
  169. std::string server_;
  170. + std::string video_url_;
  171. };
  172. #endif // WEBRTC_EXAMPLES_PEERCONNECTION_CLIENT_CONDUCTOR_H_
  173. diff --git a/webrtc/examples/peerconnection/client/flagdefs.h b/webrtc/examples/peerconnection/client/flagdefs.h
  174. index f3dda76..3331e71 100644
  175. --- a/webrtc/examples/peerconnection/client/flagdefs.h
  176. +++ b/webrtc/examples/peerconnection/client/flagdefs.h
  177. @@ -28,5 +28,6 @@ DEFINE_int(port, kDefaultServerPort,
  178. DEFINE_bool(autocall, false, "Call the first available other client on "
  179. "the server without user intervention. Note: this flag should only be set "
  180. "to true on one of the two clients.");
  181. +DEFINE_string(video_url, "parking_264.mpeg", "The URL to get an H264 video stream.");
  182. #endif // WEBRTC_EXAMPLES_PEERCONNECTION_CLIENT_FLAGDEFS_H_
  183. diff --git a/webrtc/examples/peerconnection/client/linux/main.cc b/webrtc/examples/peerconnection/client/linux/main.cc
  184. index d57bc98..1ceed0e 100644
  185. --- a/webrtc/examples/peerconnection/client/linux/main.cc
  186. +++ b/webrtc/examples/peerconnection/client/linux/main.cc
  187. @@ -8,7 +8,7 @@
  188. * be found in the AUTHORS file in the root of the source tree.
  189. */
  190. -#include <gtk/gtk.h>
  191. +//#include <gtk/gtk.h>
  192. #include "webrtc/examples/peerconnection/client/conductor.h"
  193. #include "webrtc/examples/peerconnection/client/flagdefs.h"
  194. @@ -38,14 +38,16 @@ class CustomSocketServer : public rtc::PhysicalSocketServer {
  195. // different thread. Alternatively we could look at merging the two loops
  196. // by implementing a dispatcher for the socket server and/or use
  197. // g_main_context_set_poll_func.
  198. - while (gtk_events_pending())
  199. - gtk_main_iteration();
  200. -
  201. + //while (gtk_events_pending())
  202. + //printf("~~~~~~~~~~~~~~~~~~~~~~~ /n");
  203. + //gtk_main_iteration();
  204. +#if 0
  205. if (!wnd_->IsWindow() && !conductor_->connection_active() &&
  206. client_ != NULL && !client_->is_connected()) {
  207. - message_queue_->Quit();
  208. + //message_queue_->Quit();
  209. }
  210. - return rtc::PhysicalSocketServer::Wait(0/*cms == -1 ? 1 : cms*/,
  211. +#endif
  212. + return rtc::PhysicalSocketServer::Wait(0/*cms == -1 ? 1000 : cms*/,
  213. process_io);
  214. }
  215. @@ -57,6 +59,7 @@ class CustomSocketServer : public rtc::PhysicalSocketServer {
  216. };
  217. int main(int argc, char* argv[]) {
  218. +#if 0
  219. gtk_init(&argc, &argv);
  220. // g_type_init API is deprecated (and does nothing) since glib 2.35.0, see:
  221. // https://mail.gnome.org/archives/commits-list/2012-November/msg07809.html
  222. @@ -68,6 +71,7 @@ int main(int argc, char* argv[]) {
  223. #if !GLIB_CHECK_VERSION(2, 31, 0)
  224. g_thread_init(NULL);
  225. #endif
  226. +#endif
  227. rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true);
  228. if (FLAG_help) {
  229. @@ -82,10 +86,10 @@ int main(int argc, char* argv[]) {
  230. return -1;
  231. }
  232. - GtkMainWnd wnd(FLAG_server, FLAG_port, FLAG_autoconnect, FLAG_autocall);
  233. - wnd.Create();
  234. + GtkMainWnd wnd(FLAG_server, FLAG_video_url,FLAG_port, FLAG_autoconnect, FLAG_autocall);
  235. + //wnd.Create();
  236. - CustomSocketServer socket_server(&wnd);
  237. + CustomSocketServer socket_server(/*&wnd*/NULL);
  238. rtc::AutoSocketServerThread thread(&socket_server);
  239. rtc::InitializeSSL();
  240. @@ -103,9 +107,9 @@ int main(int argc, char* argv[]) {
  241. // TODO(henrike): Run the Gtk main loop to tear down the connection.
  242. /*
  243. - while (gtk_events_pending()) {
  244. - gtk_main_iteration();
  245. - }
  246. + //while (gtk_events_pending()) {
  247. + // gtk_main_iteration();
  248. + //}
  249. */
  250. rtc::CleanupSSL();
  251. return 0;
  252. diff --git a/webrtc/examples/peerconnection/client/linux/main_wnd.cc b/webrtc/examples/peerconnection/client/linux/main_wnd.cc
  253. index d9f32bc..1ab5e14 100644
  254. --- a/webrtc/examples/peerconnection/client/linux/main_wnd.cc
  255. +++ b/webrtc/examples/peerconnection/client/linux/main_wnd.cc
  256. @@ -10,8 +10,8 @@
  257. #include "webrtc/examples/peerconnection/client/linux/main_wnd.h"
  258. -#include <gdk/gdkkeysyms.h>
  259. -#include <gtk/gtk.h>
  260. +//#include <gdk/gdkkeysyms.h>
  261. +//#include <gtk/gtk.h>
  262. #include <stddef.h>
  263. #include "libyuv/convert_from.h"
  264. @@ -29,7 +29,7 @@ namespace {
  265. // Simple static functions that simply forward the callback to the
  266. // GtkMainWnd instance.
  267. //
  268. -
  269. +#if 0
  270. gboolean OnDestroyedCallback(GtkWidget* widget, GdkEvent* event,
  271. gpointer data) {
  272. reinterpret_cast<GtkMainWnd*>(data)->OnDestroyed(widget, event);
  273. @@ -97,7 +97,7 @@ void AddToList(GtkWidget* list, const gchar* str, int value) {
  274. gtk_list_store_append(store, &iter);
  275. gtk_list_store_set(store, &iter, 0, str, 1, value, -1);
  276. }
  277. -
  278. +#endif
  279. struct UIThreadCallbackData {
  280. explicit UIThreadCallbackData(MainWndCallback* cb, int id, void* d)
  281. : callback(cb), msg_id(id), data(d) {}
  282. @@ -106,13 +106,14 @@ struct UIThreadCallbackData {
  283. void* data;
  284. };
  285. -gboolean HandleUIThreadCallback(gpointer data) {
  286. +bool HandleUIThreadCallback(void* data) {
  287. UIThreadCallbackData* cb_data = reinterpret_cast<UIThreadCallbackData*>(data);
  288. cb_data->callback->UIThreadCallback(cb_data->msg_id, cb_data->data);
  289. delete cb_data;
  290. return false;
  291. }
  292. +#if 0
  293. gboolean Redraw(gpointer data) {
  294. GtkMainWnd* wnd = reinterpret_cast<GtkMainWnd*>(data);
  295. wnd->OnRedraw();
  296. @@ -124,6 +125,7 @@ gboolean Draw(GtkWidget* widget, cairo_t* cr, gpointer data) {
  297. wnd->Draw(widget, cr);
  298. return false;
  299. }
  300. +#endif
  301. } // namespace
  302. @@ -131,11 +133,11 @@ gboolean Draw(GtkWidget* widget, cairo_t* cr, gpointer data) {
  303. // GtkMainWnd implementation.
  304. //
  305. -GtkMainWnd::GtkMainWnd(const char* server, int port, bool autoconnect,
  306. +GtkMainWnd::GtkMainWnd(const char* server, const char* video_url, int port, bool autoconnect,
  307. bool autocall)
  308. : window_(NULL), draw_area_(NULL), vbox_(NULL), server_edit_(NULL),
  309. port_edit_(NULL), peer_list_(NULL), callback_(NULL),
  310. - server_(server), autoconnect_(autoconnect), autocall_(autocall) {
  311. + server_(server), video_url_(video_url), autoconnect_(autoconnect), autocall_(autocall) {
  312. char buffer[10];
  313. sprintfn(buffer, sizeof(buffer), "%i", port);
  314. port_ = buffer;
  315. @@ -147,14 +149,16 @@ GtkMainWnd::~GtkMainWnd() {
  316. void GtkMainWnd::RegisterObserver(MainWndCallback* callback) {
  317. callback_ = callback;
  318. + callback_->StartLogin(server_, atoi(port_.c_str()), video_url_);
  319. }
  320. bool GtkMainWnd::IsWindow() {
  321. - return window_ != NULL && GTK_IS_WINDOW(window_);
  322. + return 0;//window_ != NULL && GTK_IS_WINDOW(window_);
  323. }
  324. void GtkMainWnd::MessageBox(const char* caption, const char* text,
  325. bool is_error) {
  326. +#if 0
  327. GtkWidget* dialog = gtk_message_dialog_new(GTK_WINDOW(window_),
  328. GTK_DIALOG_DESTROY_WITH_PARENT,
  329. is_error ? GTK_MESSAGE_ERROR : GTK_MESSAGE_INFO,
  330. @@ -162,6 +166,7 @@ void GtkMainWnd::MessageBox(const char* caption, const char* text,
  331. gtk_window_set_title(GTK_WINDOW(dialog), caption);
  332. gtk_dialog_run(GTK_DIALOG(dialog));
  333. gtk_widget_destroy(dialog);
  334. +#endif
  335. }
  336. MainWindow::UI GtkMainWnd::current_ui() {
  337. @@ -193,11 +198,13 @@ void GtkMainWnd::StopRemoteRenderer() {
  338. }
  339. void GtkMainWnd::QueueUIThreadCallback(int msg_id, void* data) {
  340. - g_idle_add(HandleUIThreadCallback,
  341. - new UIThreadCallbackData(callback_, msg_id, data));
  342. + /* g_idle_add(HandleUIThreadCallback,
  343. + new UIThreadCallbackData(callback_, msg_id, data));*/
  344. + HandleUIThreadCallback(new UIThreadCallbackData(callback_, msg_id, data));
  345. }
  346. bool GtkMainWnd::Create() {
  347. +#if 0
  348. RTC_DCHECK(window_ == NULL);
  349. window_ = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  350. @@ -212,7 +219,7 @@ bool GtkMainWnd::Create() {
  351. SwitchToConnectUI();
  352. }
  353. -
  354. +#endif
  355. return window_ != NULL;
  356. }
  357. @@ -220,13 +227,14 @@ bool GtkMainWnd::Destroy() {
  358. if (!IsWindow())
  359. return false;
  360. - gtk_widget_destroy(window_);
  361. + //gtk_widget_destroy(window_);
  362. window_ = NULL;
  363. return true;
  364. }
  365. void GtkMainWnd::SwitchToConnectUI() {
  366. +#if 0
  367. LOG(INFO) << __FUNCTION__;
  368. RTC_DCHECK(IsWindow());
  369. @@ -280,9 +288,11 @@ void GtkMainWnd::SwitchToConnectUI() {
  370. if (autoconnect_)
  371. g_idle_add(SimulateButtonClick, button);
  372. +#endif
  373. }
  374. void GtkMainWnd::SwitchToPeerList(const Peers& peers) {
  375. +#if 0
  376. LOG(INFO) << __FUNCTION__;
  377. if (!peer_list_) {
  378. @@ -317,9 +327,11 @@ void GtkMainWnd::SwitchToPeerList(const Peers& peers) {
  379. if (autocall_ && peers.begin() != peers.end())
  380. g_idle_add(SimulateLastRowActivated, peer_list_);
  381. +#endif
  382. }
  383. void GtkMainWnd::SwitchToStreamingUI() {
  384. +#if 0
  385. LOG(INFO) << __FUNCTION__;
  386. RTC_DCHECK(draw_area_ == NULL);
  387. @@ -335,8 +347,10 @@ void GtkMainWnd::SwitchToStreamingUI() {
  388. g_signal_connect(G_OBJECT(draw_area_), "draw", G_CALLBACK(&::Draw), this);
  389. gtk_widget_show_all(window_);
  390. +#endif
  391. }
  392. +#if 0
  393. void GtkMainWnd::OnDestroyed(GtkWidget* widget, GdkEvent* event) {
  394. callback_->Close();
  395. window_ = NULL;
  396. @@ -355,7 +369,7 @@ void GtkMainWnd::OnClicked(GtkWidget* widget) {
  397. server_ = gtk_entry_get_text(GTK_ENTRY(server_edit_));
  398. port_ = gtk_entry_get_text(GTK_ENTRY(port_edit_));
  399. int port = port_.length() ? atoi(port_.c_str()) : 0;
  400. - callback_->StartLogin(server_, port);
  401. + callback_->StartLogin(server_, port, video_url_);
  402. }
  403. void GtkMainWnd::OnKeyPress(GtkWidget* widget, GdkEventKey* key) {
  404. @@ -491,6 +505,7 @@ void GtkMainWnd::Draw(GtkWidget* widget, cairo_t* cr) {
  405. RTC_NOTREACHED();
  406. #endif
  407. }
  408. +#endif
  409. GtkMainWnd::VideoRenderer::VideoRenderer(
  410. GtkMainWnd* main_wnd,
  411. @@ -507,7 +522,7 @@ GtkMainWnd::VideoRenderer::~VideoRenderer() {
  412. }
  413. void GtkMainWnd::VideoRenderer::SetSize(int width, int height) {
  414. - gdk_threads_enter();
  415. + //gdk_threads_enter();
  416. if (width_ == width && height_ == height) {
  417. return;
  418. @@ -516,11 +531,12 @@ void GtkMainWnd::VideoRenderer::SetSize(int width, int height) {
  419. width_ = width;
  420. height_ = height;
  421. image_.reset(new uint8_t[width * height * 4]);
  422. - gdk_threads_leave();
  423. + //gdk_threads_leave();
  424. }
  425. void GtkMainWnd::VideoRenderer::OnFrame(
  426. const webrtc::VideoFrame& video_frame) {
  427. + #if 0
  428. gdk_threads_enter();
  429. rtc::scoped_refptr<webrtc::I420BufferInterface> buffer(
  430. @@ -545,4 +561,5 @@ void GtkMainWnd::VideoRenderer::OnFrame(
  431. gdk_threads_leave();
  432. g_idle_add(Redraw, main_wnd_);
  433. +#endif
  434. }
  435. diff --git a/webrtc/examples/peerconnection/client/linux/main_wnd.h b/webrtc/examples/peerconnection/client/linux/main_wnd.h
  436. index 68ed8bf..182060a 100644
  437. --- a/webrtc/examples/peerconnection/client/linux/main_wnd.h
  438. +++ b/webrtc/examples/peerconnection/client/linux/main_wnd.h
  439. @@ -31,7 +31,7 @@ typedef struct _cairo cairo_t;
  440. // implementation.
  441. class GtkMainWnd : public MainWindow {
  442. public:
  443. - GtkMainWnd(const char* server, int port, bool autoconnect, bool autocall);
  444. + GtkMainWnd(const char* server,const char* video_url, int port, bool autoconnect, bool autocall);
  445. ~GtkMainWnd();
  446. virtual void RegisterObserver(MainWndCallback* callback);
  447. @@ -112,6 +112,7 @@ class GtkMainWnd : public MainWindow {
  448. GtkWidget* peer_list_; // The list of peers.
  449. MainWndCallback* callback_;
  450. std::string server_;
  451. + std::string video_url_;
  452. std::string port_;
  453. bool autoconnect_;
  454. bool autocall_;
  455. diff --git a/webrtc/examples/peerconnection/client/main_wnd.h b/webrtc/examples/peerconnection/client/main_wnd.h
  456. index 18f56a7..8ba6518 100644
  457. --- a/webrtc/examples/peerconnection/client/main_wnd.h
  458. +++ b/webrtc/examples/peerconnection/client/main_wnd.h
  459. @@ -24,7 +24,7 @@
  460. class MainWndCallback {
  461. public:
  462. - virtual void StartLogin(const std::string& server, int port) = 0;
  463. + virtual void StartLogin(const std::string& server, int port, const std::string& video_url) = 0;
  464. virtual void DisconnectFromServer() = 0;
  465. virtual void ConnectToPeer(int peer_id) = 0;
  466. virtual void DisconnectFromCurrentPeer() = 0;
  467. diff --git a/webrtc/media/engine/webrtcvideoengine.cc b/webrtc/media/engine/webrtcvideoengine.cc
  468. index 2904bcb..d3fd5bf 100644
  469. --- a/webrtc/media/engine/webrtcvideoengine.cc
  470. +++ b/webrtc/media/engine/webrtcvideoengine.cc
  471. @@ -192,7 +192,7 @@ int GetDefaultVp9TemporalLayers() {
  472. // Constants defined in webrtc/media/engine/constants.h
  473. // TODO(pbos): Move these to a separate constants.cc file.
  474. -const int kMinVideoBitrateKbps = 30;
  475. +const int kMinVideoBitrateKbps = 30000;
  476. const int kVideoMtu = 1200;
  477. const int kVideoRtpBufferSize = 65536;
  478. @@ -406,6 +406,7 @@ static rtc::Optional<int> NextFreePayloadType(
  479. static void AppendVideoCodecs(const std::vector<VideoCodec>& input_codecs,
  480. std::vector<VideoCodec>* unified_codecs) {
  481. for (VideoCodec codec : input_codecs) {
  482. + if( codec.name == kH264CodecName ){
  483. const rtc::Optional<int> payload_type =
  484. NextFreePayloadType(*unified_codecs);
  485. if (!payload_type)
  486. @@ -437,6 +438,7 @@ static void AppendVideoCodecs(const std::vector<VideoCodec>& input_codecs,
  487. VideoCodec::CreateRtxCodec(*rtx_payload_type, codec.id));
  488. }
  489. }
  490. + }
  491. }
  492. static std::vector<VideoCodec> GetSupportedCodecs(
  493. diff --git a/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc b/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc
  494. index 290df94..e6b7133 100644
  495. --- a/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc
  496. +++ b/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc
  497. @@ -80,7 +80,9 @@ void InitializeFFmpeg() {
  498. RTC_NOTREACHED() << "av_lockmgr_register failed.";
  499. return;
  500. }
  501. + avcodec_register_all();
  502. av_register_all();
  503. + avformat_network_init();
  504. ffmpeg_initialized = true;
  505. }
  506. }
  507. @@ -89,6 +91,10 @@ void InitializeFFmpeg() {
  508. } // namespace
  509. +void H264DecoderImpl::InitFFmpeg() {
  510. + InitializeFFmpeg();
  511. +}
  512. +
  513. int H264DecoderImpl::AVGetBuffer2(
  514. AVCodecContext* context, AVFrame* av_frame, int flags) {
  515. // Set in |InitDecode|.
  516. diff --git a/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.h b/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.h
  517. index 44c2acb..e2138d2 100644
  518. --- a/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.h
  519. +++ b/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.h
  520. @@ -54,6 +54,7 @@ class H264DecoderImpl : public H264Decoder {
  521. int64_t render_time_ms = -1) override;
  522. const char* ImplementationName() const override;
  523. + void InitFFmpeg();
  524. private:
  525. // Called by FFmpeg when it needs a frame buffer to store decoded frames in.
  526. diff --git a/webrtc/modules/video_coding/codecs/h264/h264_encoder_impl.cc b/webrtc/modules/video_coding/codecs/h264/h264_encoder_impl.cc
  527. index f5a1910..b6cdc7f 100644
  528. --- a/webrtc/modules/video_coding/codecs/h264/h264_encoder_impl.cc
  529. +++ b/webrtc/modules/video_coding/codecs/h264/h264_encoder_impl.cc
  530. @@ -11,6 +11,8 @@
  531. #include "webrtc/modules/video_coding/codecs/h264/h264_encoder_impl.h"
  532. +#include "webrtc/common_video/h264/h264_common.h"
  533. +
  534. #include <limits>
  535. #include <string>
  536. @@ -55,6 +57,7 @@ int NumberOfThreads(int width, int height, int number_of_cores) {
  537. return 1;
  538. }
  539. +#if 0
  540. FrameType ConvertToVideoFrameType(EVideoFrameType type) {
  541. switch (type) {
  542. case videoFrameTypeIDR:
  543. @@ -70,6 +73,7 @@ FrameType ConvertToVideoFrameType(EVideoFrameType type) {
  544. RTC_NOTREACHED() << "Unexpected/invalid frame type: " << type;
  545. return kEmptyFrame;
  546. }
  547. +#endif
  548. } // namespace
  549. @@ -84,6 +88,7 @@ FrameType ConvertToVideoFrameType(EVideoFrameType type) {
  550. // start codes) is copied to the |encoded_image->_buffer| and the |frag_header|
  551. // is updated to point to each fragment, with offsets and lengths set as to
  552. // exclude the start codes.
  553. +#if 0
  554. static void RtpFragmentize(EncodedImage* encoded_image,
  555. std::unique_ptr<uint8_t[]>* encoded_image_buffer,
  556. const VideoFrameBuffer& frame_buffer,
  557. @@ -151,6 +156,7 @@ static void RtpFragmentize(EncodedImage* encoded_image,
  558. encoded_image->_length += layer_len;
  559. }
  560. }
  561. +#endif
  562. H264EncoderImpl::H264EncoderImpl(const cricket::VideoCodec& codec)
  563. : openh264_encoder_(nullptr),
  564. @@ -314,7 +320,7 @@ int32_t H264EncoderImpl::Encode(const VideoFrame& input_frame,
  565. ReportError();
  566. return WEBRTC_VIDEO_CODEC_UNINITIALIZED;
  567. }
  568. -
  569. +#if 0
  570. bool force_key_frame = false;
  571. if (frame_types != nullptr) {
  572. // We only support a single stream.
  573. @@ -360,7 +366,9 @@ int32_t H264EncoderImpl::Encode(const VideoFrame& input_frame,
  574. ReportError();
  575. return WEBRTC_VIDEO_CODEC_ERROR;
  576. }
  577. -
  578. +#endif
  579. + rtc::scoped_refptr<const VideoFrameBuffer> frame_buffer = input_frame.video_frame_buffer();
  580. + rtc::scoped_refptr<const I420BufferInterface> I420_interf = frame_buffer->GetI420();
  581. encoded_image_._encodedWidth = frame_buffer->width();
  582. encoded_image_._encodedHeight = frame_buffer->height();
  583. encoded_image_._timeStamp = input_frame.timestamp();
  584. @@ -371,21 +379,103 @@ int32_t H264EncoderImpl::Encode(const VideoFrame& input_frame,
  585. ? VideoContentType::SCREENSHARE
  586. : VideoContentType::UNSPECIFIED;
  587. encoded_image_.timing_.flags = TimingFrameFlags::kInvalid;
  588. - encoded_image_._frameType = ConvertToVideoFrameType(info.eFrameType);
  589. + //encoded_image_._frameType = ConvertToVideoFrameType(info.eFrameType);
  590. // Split encoded image up into fragments. This also updates |encoded_image_|.
  591. RTPFragmentationHeader frag_header;
  592. +#if 0
  593. RtpFragmentize(&encoded_image_, &encoded_image_buffer_, *frame_buffer, &info,
  594. &frag_header);
  595. +#else
  596. + uint8_t * p_nal = const_cast<uint8_t*>(I420_interf->DataY())+5;
  597. + uint32_t * p_size;
  598. + uint8_t * p_prio;
  599. + uint8_t new_prio = 0x03; // priority is set to 3 by default
  600. + int i_nal ;
  601. + static int fr_num = 0;
  602. + std::vector<H264::NaluIndex> NALUidx;
  603. + p_size = (uint32_t*)(I420_interf->DataY()) ;
  604. + p_prio = (uint8_t*)(I420_interf->DataY()) +4 ; //&new_prio
  605. + new_prio = p_prio[0];
  606. +
  607. +
  608. + NALUidx = H264::FindNaluIndices(p_nal , p_size[0]);
  609. + i_nal = NALUidx.size();
  610. + //if( i_nal > 2 )
  611. + // NALUidx[i_nal-1].payload_size = p_size[0] - NALUidx[i_nal-1].payload_start_offset ;
  612. + for (int nal_index = 0; nal_index < i_nal ; nal_index++)
  613. + {
  614. + uint8_t nal = p_nal[NALUidx[nal_index].payload_start_offset] ;
  615. + if( nal == 0x09 ){ // remove NALU delimiters...
  616. + NALUidx.erase (NALUidx.begin()+nal_index);
  617. + }
  618. +
  619. + }
  620. + i_nal = NALUidx.size();
  621. + frag_header.VerifyAndAllocateFragmentationHeader(i_nal);
  622. + //debug gdb: x/100bx p_nal
  623. + encoded_image_._length = 0;
  624. +
  625. + uint32_t totalNaluIndex = 0;
  626. +
  627. + for (int nal_index = 0; nal_index < i_nal ; nal_index++)
  628. + {
  629. + uint32_t currentNaluSize = 0;
  630. +
  631. + uint8_t nal = p_nal[NALUidx[nal_index].payload_start_offset] ;
  632. + //if( nal == 0x09 ){
  633. + // totalNaluIndex++;
  634. + // continue;
  635. + //}
  636. +
  637. + if(p_prio[0] < 3)
  638. + {
  639. + // uint32_t type = nal&0x1F;
  640. + uint8_t ref_idc = (nal >>5)&0x03;
  641. +
  642. + if(ref_idc == 0 )
  643. + {
  644. + new_prio = (p_prio[0]+2)%4;
  645. +
  646. + }
  647. + uint8_t nri_mask = ( new_prio << 5 ) & 0x60;
  648. + p_nal[NALUidx[nal_index].payload_start_offset] = (p_nal[NALUidx[nal_index].payload_start_offset] & 0x9F) | nri_mask;
  649. + nal = p_nal[NALUidx[nal_index].payload_start_offset] ;
  650. + ref_idc = (nal >>5)&0x03;
  651. +
  652. + }
  653. + // break;//p_nal[NALUidx[nal_index].payload_start_offset] = 0x01;
  654. +
  655. + // printf("%02x -- %02x \n",nal, type);
  656. + currentNaluSize = NALUidx[nal_index].payload_size; //i_frame_size
  657. +
  658. + // printf("%02x -- %02x ---%u \n",nal, type, currentNaluSize);
  659. + memcpy(encoded_image_._buffer + encoded_image_._length, &p_nal[NALUidx[nal_index].payload_start_offset] , currentNaluSize);//will add start code automatically
  660. + encoded_image_._length += currentNaluSize;
  661. +
  662. + frag_header.fragmentationOffset[totalNaluIndex] = encoded_image_._length - currentNaluSize;
  663. + frag_header.fragmentationLength[totalNaluIndex] = currentNaluSize;
  664. + frag_header.fragmentationPlType[totalNaluIndex] = H264::ParseNaluType(p_nal[NALUidx[nal_index].payload_start_offset]);
  665. + frag_header.fragmentationTimeDiff[totalNaluIndex] = 0;
  666. + //printf("%04x",frag_header.fragmentationPlType[totalNaluIndex]);
  667. + //printf("\n");
  668. +
  669. + totalNaluIndex++;
  670. +
  671. + }
  672. + fr_num++;
  673. +
  674. +#endif
  675. // Encoder can skip frames to save bandwidth in which case
  676. // |encoded_image_._length| == 0.
  677. if (encoded_image_._length > 0) {
  678. +#if 0
  679. // Parse QP.
  680. h264_bitstream_parser_.ParseBitstream(encoded_image_._buffer,
  681. encoded_image_._length);
  682. h264_bitstream_parser_.GetLastSliceQp(&encoded_image_.qp_);
  683. -
  684. +#endif
  685. // Deliver encoded image.
  686. CodecSpecificInfo codec_specific;
  687. codec_specific.codecType = kVideoCodecH264;
  688. @@ -430,7 +520,7 @@ SEncParamExt H264EncoderImpl::CreateEncoderParams() const {
  689. // The following parameters are extension parameters (they're in SEncParamExt,
  690. // not in SEncParamBase).
  691. - encoder_params.bEnableFrameSkip = frame_dropping_on_;
  692. + encoder_params.bEnableFrameSkip = false;//frame_dropping_on_;
  693. // |uiIntraPeriod| - multiple of GOP size
  694. // |keyFrameInterval| - number of frames
  695. encoder_params.uiIntraPeriod = key_frame_interval_;
  696. @@ -447,8 +537,7 @@ SEncParamExt H264EncoderImpl::CreateEncoderParams() const {
  697. encoder_params.sSpatialLayers[0].fFrameRate = encoder_params.fMaxFrameRate;
  698. encoder_params.sSpatialLayers[0].iSpatialBitrate =
  699. encoder_params.iTargetBitrate;
  700. - encoder_params.sSpatialLayers[0].iMaxSpatialBitrate =
  701. - encoder_params.iMaxBitrate;
  702. + encoder_params.sSpatialLayers[0].iMaxSpatialBitrate = 40000000;// encoder_params.iMaxBitrate;
  703. LOG(INFO) << "OpenH264 version is " << OPENH264_MAJOR << "."
  704. << OPENH264_MINOR;
  705. switch (packetization_mode_) {
  706. diff --git a/webrtc/modules/video_coding/codecs/vp8/vp8_impl.cc b/webrtc/modules/video_coding/codecs/vp8/vp8_impl.cc
  707. index 3bf85d5..0987717 100644
  708. --- a/webrtc/modules/video_coding/codecs/vp8/vp8_impl.cc
  709. +++ b/webrtc/modules/video_coding/codecs/vp8/vp8_impl.cc
  710. @@ -289,9 +289,9 @@ int VP8EncoderImpl::SetRateAllocation(const BitrateAllocation& bitrate,
  711. // At this point, bitrate allocation should already match codec settings.
  712. if (codec_.maxBitrate > 0)
  713. RTC_DCHECK_LE(bitrate.get_sum_kbps(), codec_.maxBitrate);
  714. - RTC_DCHECK_GE(bitrate.get_sum_kbps(), codec_.minBitrate);
  715. + //RTC_DCHECK_GE(bitrate.get_sum_kbps(), codec_.minBitrate);
  716. if (codec_.numberOfSimulcastStreams > 0)
  717. - RTC_DCHECK_GE(bitrate.get_sum_kbps(), codec_.simulcastStream[0].minBitrate);
  718. + //RTC_DCHECK_GE(bitrate.get_sum_kbps(), codec_.simulcastStream[0].minBitrate);
  719. codec_.maxFramerate = new_framerate;
  720. diff --git a/webrtc/modules/video_coding/video_codec_initializer.cc b/webrtc/modules/video_coding/video_codec_initializer.cc
  721. index d274bf1..d87750c 100644
  722. --- a/webrtc/modules/video_coding/video_codec_initializer.cc
  723. +++ b/webrtc/modules/video_coding/video_codec_initializer.cc
  724. @@ -202,7 +202,7 @@ VideoCodec VideoCodecInitializer::VideoEncoderConfigToVideoCodec(
  725. RTC_DCHECK_EQ(streams[i].max_framerate, streams[0].max_framerate);
  726. }
  727. RTC_DCHECK_GE(streams[i].min_bitrate_bps, 0);
  728. - RTC_DCHECK_GE(streams[i].target_bitrate_bps, streams[i].min_bitrate_bps);
  729. + //RTC_DCHECK_GE(streams[i].target_bitrate_bps, streams[i].min_bitrate_bps);
  730. RTC_DCHECK_GE(streams[i].max_bitrate_bps, streams[i].target_bitrate_bps);
  731. RTC_DCHECK_GE(streams[i].max_qp, 0);
  732. diff --git a/webrtc/modules/video_coding/video_sender.cc b/webrtc/modules/video_coding/video_sender.cc
  733. index f60b687..4ddbfd0 100644
  734. --- a/webrtc/modules/video_coding/video_sender.cc
  735. +++ b/webrtc/modules/video_coding/video_sender.cc
  736. @@ -37,7 +37,7 @@ VideoSender::VideoSender(Clock* clock,
  737. post_encode_callback_(post_encode_callback),
  738. send_stats_callback_(send_stats_callback),
  739. _codecDataBase(&_encodedFrameCallback),
  740. - frame_dropper_enabled_(true),
  741. + frame_dropper_enabled_(false),
  742. _sendStatsTimer(VCMProcessTimer::kDefaultProcessIntervalMs, clock_),
  743. current_codec_(),
  744. encoder_params_({BitrateAllocation(), 0, 0, 0}),
  745. @@ -120,7 +120,7 @@ int32_t VideoSender::RegisterSendCodec(const VideoCodec* sendCodec,
  746. } else if (frame_dropper_enabled_) {
  747. _mediaOpt.EnableFrameDropper(true);
  748. }
  749. -
  750. + _mediaOpt.EnableFrameDropper(false);
  751. {
  752. rtc::CritScope cs(&params_crit_);
  753. next_frame_types_.clear();
  754. diff --git a/webrtc/pc/jsepsessiondescription.cc b/webrtc/pc/jsepsessiondescription.cc
  755. index 2e972ea..d701d70 100644
  756. --- a/webrtc/pc/jsepsessiondescription.cc
  757. +++ b/webrtc/pc/jsepsessiondescription.cc
  758. @@ -110,8 +110,8 @@ const char SessionDescriptionInterface::kOffer[] = "offer";
  759. const char SessionDescriptionInterface::kPrAnswer[] = "pranswer";
  760. const char SessionDescriptionInterface::kAnswer[] = "answer";
  761. -const int JsepSessionDescription::kDefaultVideoCodecId = 100;
  762. -const char JsepSessionDescription::kDefaultVideoCodecName[] = "VP8";
  763. +const int JsepSessionDescription::kDefaultVideoCodecId = 126;
  764. +const char JsepSessionDescription::kDefaultVideoCodecName[] = "H264";
  765. SessionDescriptionInterface* CreateSessionDescription(const std::string& type,
  766. const std::string& sdp,