Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: talk/session/media/channel.cc

Issue 1362503003: Use suffixed {uint,int}{8,16,32,64}_t types. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase + revert basictypes.h (to be landed separately just in case of a revert due to unexpected us… Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « talk/session/media/channel.h ('k') | talk/session/media/channel_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * libjingle 2 * libjingle
3 * Copyright 2004 Google Inc. 3 * Copyright 2004 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 *error_desc = message; 64 *error_desc = message;
65 } 65 }
66 } 66 }
67 67
68 struct PacketMessageData : public rtc::MessageData { 68 struct PacketMessageData : public rtc::MessageData {
69 rtc::Buffer packet; 69 rtc::Buffer packet;
70 rtc::DiffServCodePoint dscp; 70 rtc::DiffServCodePoint dscp;
71 }; 71 };
72 72
73 struct ScreencastEventMessageData : public rtc::MessageData { 73 struct ScreencastEventMessageData : public rtc::MessageData {
74 ScreencastEventMessageData(uint32 s, rtc::WindowEvent we) 74 ScreencastEventMessageData(uint32_t s, rtc::WindowEvent we)
75 : ssrc(s), 75 : ssrc(s), event(we) {}
76 event(we) { 76 uint32_t ssrc;
77 }
78 uint32 ssrc;
79 rtc::WindowEvent event; 77 rtc::WindowEvent event;
80 }; 78 };
81 79
82 struct VoiceChannelErrorMessageData : public rtc::MessageData { 80 struct VoiceChannelErrorMessageData : public rtc::MessageData {
83 VoiceChannelErrorMessageData(uint32 in_ssrc, 81 VoiceChannelErrorMessageData(uint32_t in_ssrc,
84 VoiceMediaChannel::Error in_error) 82 VoiceMediaChannel::Error in_error)
85 : ssrc(in_ssrc), 83 : ssrc(in_ssrc), error(in_error) {}
86 error(in_error) { 84 uint32_t ssrc;
87 }
88 uint32 ssrc;
89 VoiceMediaChannel::Error error; 85 VoiceMediaChannel::Error error;
90 }; 86 };
91 87
92 struct VideoChannelErrorMessageData : public rtc::MessageData { 88 struct VideoChannelErrorMessageData : public rtc::MessageData {
93 VideoChannelErrorMessageData(uint32 in_ssrc, 89 VideoChannelErrorMessageData(uint32_t in_ssrc,
94 VideoMediaChannel::Error in_error) 90 VideoMediaChannel::Error in_error)
95 : ssrc(in_ssrc), 91 : ssrc(in_ssrc), error(in_error) {}
96 error(in_error) { 92 uint32_t ssrc;
97 }
98 uint32 ssrc;
99 VideoMediaChannel::Error error; 93 VideoMediaChannel::Error error;
100 }; 94 };
101 95
102 struct DataChannelErrorMessageData : public rtc::MessageData { 96 struct DataChannelErrorMessageData : public rtc::MessageData {
103 DataChannelErrorMessageData(uint32 in_ssrc, 97 DataChannelErrorMessageData(uint32_t in_ssrc,
104 DataMediaChannel::Error in_error) 98 DataMediaChannel::Error in_error)
105 : ssrc(in_ssrc), 99 : ssrc(in_ssrc), error(in_error) {}
106 error(in_error) {} 100 uint32_t ssrc;
107 uint32 ssrc;
108 DataMediaChannel::Error error; 101 DataMediaChannel::Error error;
109 }; 102 };
110 103
111 104
112 struct VideoChannel::ScreencastDetailsData { 105 struct VideoChannel::ScreencastDetailsData {
113 explicit ScreencastDetailsData(uint32 s) 106 explicit ScreencastDetailsData(uint32_t s)
114 : ssrc(s), fps(0), screencast_max_pixels(0) { 107 : ssrc(s), fps(0), screencast_max_pixels(0) {}
115 } 108 uint32_t ssrc;
116 uint32 ssrc;
117 int fps; 109 int fps;
118 int screencast_max_pixels; 110 int screencast_max_pixels;
119 }; 111 };
120 112
121 static const char* PacketType(bool rtcp) { 113 static const char* PacketType(bool rtcp) {
122 return (!rtcp) ? "RTP" : "RTCP"; 114 return (!rtcp) ? "RTP" : "RTCP";
123 } 115 }
124 116
125 static bool ValidPacket(bool rtcp, const rtc::Buffer* packet) { 117 static bool ValidPacket(bool rtcp, const rtc::Buffer* packet) {
126 // Check the packet size. We could check the header too if needed. 118 // Check the packet size. We could check the header too if needed.
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 worker_thread_->Invoke<void>(Bind( 350 worker_thread_->Invoke<void>(Bind(
359 enable ? &BaseChannel::EnableMedia_w : &BaseChannel::DisableMedia_w, 351 enable ? &BaseChannel::EnableMedia_w : &BaseChannel::DisableMedia_w,
360 this)); 352 this));
361 return true; 353 return true;
362 } 354 }
363 355
364 bool BaseChannel::AddRecvStream(const StreamParams& sp) { 356 bool BaseChannel::AddRecvStream(const StreamParams& sp) {
365 return InvokeOnWorker(Bind(&BaseChannel::AddRecvStream_w, this, sp)); 357 return InvokeOnWorker(Bind(&BaseChannel::AddRecvStream_w, this, sp));
366 } 358 }
367 359
368 bool BaseChannel::RemoveRecvStream(uint32 ssrc) { 360 bool BaseChannel::RemoveRecvStream(uint32_t ssrc) {
369 return InvokeOnWorker(Bind(&BaseChannel::RemoveRecvStream_w, this, ssrc)); 361 return InvokeOnWorker(Bind(&BaseChannel::RemoveRecvStream_w, this, ssrc));
370 } 362 }
371 363
372 bool BaseChannel::AddSendStream(const StreamParams& sp) { 364 bool BaseChannel::AddSendStream(const StreamParams& sp) {
373 return InvokeOnWorker( 365 return InvokeOnWorker(
374 Bind(&MediaChannel::AddSendStream, media_channel(), sp)); 366 Bind(&MediaChannel::AddSendStream, media_channel(), sp));
375 } 367 }
376 368
377 bool BaseChannel::RemoveSendStream(uint32 ssrc) { 369 bool BaseChannel::RemoveSendStream(uint32_t ssrc) {
378 return InvokeOnWorker( 370 return InvokeOnWorker(
379 Bind(&MediaChannel::RemoveSendStream, media_channel(), ssrc)); 371 Bind(&MediaChannel::RemoveSendStream, media_channel(), ssrc));
380 } 372 }
381 373
382 bool BaseChannel::SetLocalContent(const MediaContentDescription* content, 374 bool BaseChannel::SetLocalContent(const MediaContentDescription* content,
383 ContentAction action, 375 ContentAction action,
384 std::string* error_desc) { 376 std::string* error_desc) {
385 return InvokeOnWorker(Bind(&BaseChannel::SetLocalContent_w, 377 return InvokeOnWorker(Bind(&BaseChannel::SetLocalContent_w,
386 this, content, action, error_desc)); 378 this, content, action, error_desc));
387 } 379 }
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 res = srtp_filter_.ProtectRtp( 551 res = srtp_filter_.ProtectRtp(
560 data, len, static_cast<int>(packet->capacity()), &len); 552 data, len, static_cast<int>(packet->capacity()), &len);
561 #else 553 #else
562 options.packet_time_params.rtp_sendtime_extension_id = 554 options.packet_time_params.rtp_sendtime_extension_id =
563 rtp_abs_sendtime_extn_id_; 555 rtp_abs_sendtime_extn_id_;
564 res = srtp_filter_.ProtectRtp( 556 res = srtp_filter_.ProtectRtp(
565 data, len, static_cast<int>(packet->capacity()), &len, 557 data, len, static_cast<int>(packet->capacity()), &len,
566 &options.packet_time_params.srtp_packet_index); 558 &options.packet_time_params.srtp_packet_index);
567 // If protection succeeds, let's get auth params from srtp. 559 // If protection succeeds, let's get auth params from srtp.
568 if (res) { 560 if (res) {
569 uint8* auth_key = NULL; 561 uint8_t* auth_key = NULL;
570 int key_len; 562 int key_len;
571 res = srtp_filter_.GetRtpAuthParams( 563 res = srtp_filter_.GetRtpAuthParams(
572 &auth_key, &key_len, &options.packet_time_params.srtp_auth_tag_len); 564 &auth_key, &key_len, &options.packet_time_params.srtp_auth_tag_len);
573 if (res) { 565 if (res) {
574 options.packet_time_params.srtp_auth_key.resize(key_len); 566 options.packet_time_params.srtp_auth_key.resize(key_len);
575 options.packet_time_params.srtp_auth_key.assign(auth_key, 567 options.packet_time_params.srtp_auth_key.assign(auth_key,
576 auth_key + key_len); 568 auth_key + key_len);
577 } 569 }
578 } 570 }
579 #endif 571 #endif
580 if (!res) { 572 if (!res) {
581 int seq_num = -1; 573 int seq_num = -1;
582 uint32 ssrc = 0; 574 uint32_t ssrc = 0;
583 GetRtpSeqNum(data, len, &seq_num); 575 GetRtpSeqNum(data, len, &seq_num);
584 GetRtpSsrc(data, len, &ssrc); 576 GetRtpSsrc(data, len, &ssrc);
585 LOG(LS_ERROR) << "Failed to protect " << content_name_ 577 LOG(LS_ERROR) << "Failed to protect " << content_name_
586 << " RTP packet: size=" << len 578 << " RTP packet: size=" << len
587 << ", seqnum=" << seq_num << ", SSRC=" << ssrc; 579 << ", seqnum=" << seq_num << ", SSRC=" << ssrc;
588 return false; 580 return false;
589 } 581 }
590 } else { 582 } else {
591 res = srtp_filter_.ProtectRtcp(data, len, 583 res = srtp_filter_.ProtectRtcp(data, len,
592 static_cast<int>(packet->capacity()), 584 static_cast<int>(packet->capacity()),
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 645
654 // Unprotect the packet, if needed. 646 // Unprotect the packet, if needed.
655 if (srtp_filter_.IsActive()) { 647 if (srtp_filter_.IsActive()) {
656 char* data = packet->data<char>(); 648 char* data = packet->data<char>();
657 int len = static_cast<int>(packet->size()); 649 int len = static_cast<int>(packet->size());
658 bool res; 650 bool res;
659 if (!rtcp) { 651 if (!rtcp) {
660 res = srtp_filter_.UnprotectRtp(data, len, &len); 652 res = srtp_filter_.UnprotectRtp(data, len, &len);
661 if (!res) { 653 if (!res) {
662 int seq_num = -1; 654 int seq_num = -1;
663 uint32 ssrc = 0; 655 uint32_t ssrc = 0;
664 GetRtpSeqNum(data, len, &seq_num); 656 GetRtpSeqNum(data, len, &seq_num);
665 GetRtpSsrc(data, len, &ssrc); 657 GetRtpSsrc(data, len, &ssrc);
666 LOG(LS_ERROR) << "Failed to unprotect " << content_name_ 658 LOG(LS_ERROR) << "Failed to unprotect " << content_name_
667 << " RTP packet: size=" << len 659 << " RTP packet: size=" << len
668 << ", seqnum=" << seq_num << ", SSRC=" << ssrc; 660 << ", seqnum=" << seq_num << ", SSRC=" << ssrc;
669 return; 661 return;
670 } 662 }
671 } else { 663 } else {
672 res = srtp_filter_.UnprotectRtcp(data, len, &len); 664 res = srtp_filter_.UnprotectRtcp(data, len, &len);
673 if (!res) { 665 if (!res) {
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
1079 } 1071 }
1080 1072
1081 bool BaseChannel::AddRecvStream_w(const StreamParams& sp) { 1073 bool BaseChannel::AddRecvStream_w(const StreamParams& sp) {
1082 ASSERT(worker_thread() == rtc::Thread::Current()); 1074 ASSERT(worker_thread() == rtc::Thread::Current());
1083 if (!media_channel()->AddRecvStream(sp)) 1075 if (!media_channel()->AddRecvStream(sp))
1084 return false; 1076 return false;
1085 1077
1086 return bundle_filter_.AddStream(sp); 1078 return bundle_filter_.AddStream(sp);
1087 } 1079 }
1088 1080
1089 bool BaseChannel::RemoveRecvStream_w(uint32 ssrc) { 1081 bool BaseChannel::RemoveRecvStream_w(uint32_t ssrc) {
1090 ASSERT(worker_thread() == rtc::Thread::Current()); 1082 ASSERT(worker_thread() == rtc::Thread::Current());
1091 bundle_filter_.RemoveStream(ssrc); 1083 bundle_filter_.RemoveStream(ssrc);
1092 return media_channel()->RemoveRecvStream(ssrc); 1084 return media_channel()->RemoveRecvStream(ssrc);
1093 } 1085 }
1094 1086
1095 bool BaseChannel::UpdateLocalStreams_w(const std::vector<StreamParams>& streams, 1087 bool BaseChannel::UpdateLocalStreams_w(const std::vector<StreamParams>& streams,
1096 ContentAction action, 1088 ContentAction action,
1097 std::string* error_desc) { 1089 std::string* error_desc) {
1098 if (!VERIFY(action == CA_OFFER || action == CA_ANSWER || 1090 if (!VERIFY(action == CA_OFFER || action == CA_ANSWER ||
1099 action == CA_PRANSWER || action == CA_UPDATE)) 1091 action == CA_PRANSWER || action == CA_UPDATE))
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
1297 Deinit(); 1289 Deinit();
1298 } 1290 }
1299 1291
1300 bool VoiceChannel::Init() { 1292 bool VoiceChannel::Init() {
1301 if (!BaseChannel::Init()) { 1293 if (!BaseChannel::Init()) {
1302 return false; 1294 return false;
1303 } 1295 }
1304 return true; 1296 return true;
1305 } 1297 }
1306 1298
1307 bool VoiceChannel::SetRemoteRenderer(uint32 ssrc, AudioRenderer* renderer) { 1299 bool VoiceChannel::SetRemoteRenderer(uint32_t ssrc, AudioRenderer* renderer) {
1308 return InvokeOnWorker(Bind(&VoiceMediaChannel::SetRemoteRenderer, 1300 return InvokeOnWorker(Bind(&VoiceMediaChannel::SetRemoteRenderer,
1309 media_channel(), ssrc, renderer)); 1301 media_channel(), ssrc, renderer));
1310 } 1302 }
1311 1303
1312 bool VoiceChannel::SetAudioSend(uint32 ssrc, 1304 bool VoiceChannel::SetAudioSend(uint32_t ssrc,
1313 bool enable, 1305 bool enable,
1314 const AudioOptions* options, 1306 const AudioOptions* options,
1315 AudioRenderer* renderer) { 1307 AudioRenderer* renderer) {
1316 return InvokeOnWorker(Bind(&VoiceMediaChannel::SetAudioSend, media_channel(), 1308 return InvokeOnWorker(Bind(&VoiceMediaChannel::SetAudioSend, media_channel(),
1317 ssrc, enable, options, renderer)); 1309 ssrc, enable, options, renderer));
1318 } 1310 }
1319 1311
1320 // TODO(juberti): Handle early media the right way. We should get an explicit 1312 // TODO(juberti): Handle early media the right way. We should get an explicit
1321 // ringing message telling us to start playing local ringback, which we cancel 1313 // ringing message telling us to start playing local ringback, which we cancel
1322 // if any early media actually arrives. For now, we do the opposite, which is 1314 // if any early media actually arrives. For now, we do the opposite, which is
(...skipping 17 matching lines...) Expand all
1340 } 1332 }
1341 int duration_ms = 160; 1333 int duration_ms = 160;
1342 return InsertDtmf(0, digit, duration_ms, flags); 1334 return InsertDtmf(0, digit, duration_ms, flags);
1343 } 1335 }
1344 1336
1345 bool VoiceChannel::CanInsertDtmf() { 1337 bool VoiceChannel::CanInsertDtmf() {
1346 return InvokeOnWorker(Bind(&VoiceMediaChannel::CanInsertDtmf, 1338 return InvokeOnWorker(Bind(&VoiceMediaChannel::CanInsertDtmf,
1347 media_channel())); 1339 media_channel()));
1348 } 1340 }
1349 1341
1350 bool VoiceChannel::InsertDtmf(uint32 ssrc, int event_code, int duration, 1342 bool VoiceChannel::InsertDtmf(uint32_t ssrc,
1343 int event_code,
1344 int duration,
1351 int flags) { 1345 int flags) {
1352 return InvokeOnWorker(Bind(&VoiceChannel::InsertDtmf_w, this, 1346 return InvokeOnWorker(Bind(&VoiceChannel::InsertDtmf_w, this,
1353 ssrc, event_code, duration, flags)); 1347 ssrc, event_code, duration, flags));
1354 } 1348 }
1355 1349
1356 bool VoiceChannel::SetOutputScaling(uint32 ssrc, double left, double right) { 1350 bool VoiceChannel::SetOutputScaling(uint32_t ssrc, double left, double right) {
1357 return InvokeOnWorker(Bind(&VoiceMediaChannel::SetOutputScaling, 1351 return InvokeOnWorker(Bind(&VoiceMediaChannel::SetOutputScaling,
1358 media_channel(), ssrc, left, right)); 1352 media_channel(), ssrc, left, right));
1359 } 1353 }
1360 1354
1361 bool VoiceChannel::GetStats(VoiceMediaInfo* stats) { 1355 bool VoiceChannel::GetStats(VoiceMediaInfo* stats) {
1362 return InvokeOnWorker(Bind(&VoiceMediaChannel::GetStats, 1356 return InvokeOnWorker(Bind(&VoiceMediaChannel::GetStats,
1363 media_channel(), stats)); 1357 media_channel(), stats));
1364 } 1358 }
1365 1359
1366 void VoiceChannel::StartMediaMonitor(int cms) { 1360 void VoiceChannel::StartMediaMonitor(int cms) {
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
1540 } 1534 }
1541 1535
1542 void VoiceChannel::HandleEarlyMediaTimeout() { 1536 void VoiceChannel::HandleEarlyMediaTimeout() {
1543 // This occurs on the main thread, not the worker thread. 1537 // This occurs on the main thread, not the worker thread.
1544 if (!received_media_) { 1538 if (!received_media_) {
1545 LOG(LS_INFO) << "No early media received before timeout"; 1539 LOG(LS_INFO) << "No early media received before timeout";
1546 SignalEarlyMediaTimeout(this); 1540 SignalEarlyMediaTimeout(this);
1547 } 1541 }
1548 } 1542 }
1549 1543
1550 bool VoiceChannel::InsertDtmf_w(uint32 ssrc, int event, int duration, 1544 bool VoiceChannel::InsertDtmf_w(uint32_t ssrc,
1545 int event,
1546 int duration,
1551 int flags) { 1547 int flags) {
1552 if (!enabled()) { 1548 if (!enabled()) {
1553 return false; 1549 return false;
1554 } 1550 }
1555 1551
1556 return media_channel()->InsertDtmf(ssrc, event, duration, flags); 1552 return media_channel()->InsertDtmf(ssrc, event, duration, flags);
1557 } 1553 }
1558 1554
1559 void VoiceChannel::OnMessage(rtc::Message *pmsg) { 1555 void VoiceChannel::OnMessage(rtc::Message *pmsg) {
1560 switch (pmsg->message_id) { 1556 switch (pmsg->message_id) {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1608 previous_we_(rtc::WE_CLOSE) {} 1604 previous_we_(rtc::WE_CLOSE) {}
1609 1605
1610 bool VideoChannel::Init() { 1606 bool VideoChannel::Init() {
1611 if (!BaseChannel::Init()) { 1607 if (!BaseChannel::Init()) {
1612 return false; 1608 return false;
1613 } 1609 }
1614 return true; 1610 return true;
1615 } 1611 }
1616 1612
1617 VideoChannel::~VideoChannel() { 1613 VideoChannel::~VideoChannel() {
1618 std::vector<uint32> screencast_ssrcs; 1614 std::vector<uint32_t> screencast_ssrcs;
1619 ScreencastMap::iterator iter; 1615 ScreencastMap::iterator iter;
1620 while (!screencast_capturers_.empty()) { 1616 while (!screencast_capturers_.empty()) {
1621 if (!RemoveScreencast(screencast_capturers_.begin()->first)) { 1617 if (!RemoveScreencast(screencast_capturers_.begin()->first)) {
1622 LOG(LS_ERROR) << "Unable to delete screencast with ssrc " 1618 LOG(LS_ERROR) << "Unable to delete screencast with ssrc "
1623 << screencast_capturers_.begin()->first; 1619 << screencast_capturers_.begin()->first;
1624 ASSERT(false); 1620 ASSERT(false);
1625 break; 1621 break;
1626 } 1622 }
1627 } 1623 }
1628 1624
1629 StopMediaMonitor(); 1625 StopMediaMonitor();
1630 // this can't be done in the base class, since it calls a virtual 1626 // this can't be done in the base class, since it calls a virtual
1631 DisableMedia_w(); 1627 DisableMedia_w();
1632 1628
1633 Deinit(); 1629 Deinit();
1634 } 1630 }
1635 1631
1636 bool VideoChannel::SetRenderer(uint32 ssrc, VideoRenderer* renderer) { 1632 bool VideoChannel::SetRenderer(uint32_t ssrc, VideoRenderer* renderer) {
1637 worker_thread()->Invoke<void>(Bind( 1633 worker_thread()->Invoke<void>(Bind(
1638 &VideoMediaChannel::SetRenderer, media_channel(), ssrc, renderer)); 1634 &VideoMediaChannel::SetRenderer, media_channel(), ssrc, renderer));
1639 return true; 1635 return true;
1640 } 1636 }
1641 1637
1642 bool VideoChannel::ApplyViewRequest(const ViewRequest& request) { 1638 bool VideoChannel::ApplyViewRequest(const ViewRequest& request) {
1643 return InvokeOnWorker(Bind(&VideoChannel::ApplyViewRequest_w, this, request)); 1639 return InvokeOnWorker(Bind(&VideoChannel::ApplyViewRequest_w, this, request));
1644 } 1640 }
1645 1641
1646 bool VideoChannel::AddScreencast(uint32 ssrc, VideoCapturer* capturer) { 1642 bool VideoChannel::AddScreencast(uint32_t ssrc, VideoCapturer* capturer) {
1647 return worker_thread()->Invoke<bool>(Bind( 1643 return worker_thread()->Invoke<bool>(Bind(
1648 &VideoChannel::AddScreencast_w, this, ssrc, capturer)); 1644 &VideoChannel::AddScreencast_w, this, ssrc, capturer));
1649 } 1645 }
1650 1646
1651 bool VideoChannel::SetCapturer(uint32 ssrc, VideoCapturer* capturer) { 1647 bool VideoChannel::SetCapturer(uint32_t ssrc, VideoCapturer* capturer) {
1652 return InvokeOnWorker(Bind(&VideoMediaChannel::SetCapturer, 1648 return InvokeOnWorker(Bind(&VideoMediaChannel::SetCapturer,
1653 media_channel(), ssrc, capturer)); 1649 media_channel(), ssrc, capturer));
1654 } 1650 }
1655 1651
1656 bool VideoChannel::RemoveScreencast(uint32 ssrc) { 1652 bool VideoChannel::RemoveScreencast(uint32_t ssrc) {
1657 return InvokeOnWorker(Bind(&VideoChannel::RemoveScreencast_w, this, ssrc)); 1653 return InvokeOnWorker(Bind(&VideoChannel::RemoveScreencast_w, this, ssrc));
1658 } 1654 }
1659 1655
1660 bool VideoChannel::IsScreencasting() { 1656 bool VideoChannel::IsScreencasting() {
1661 return InvokeOnWorker(Bind(&VideoChannel::IsScreencasting_w, this)); 1657 return InvokeOnWorker(Bind(&VideoChannel::IsScreencasting_w, this));
1662 } 1658 }
1663 1659
1664 int VideoChannel::GetScreencastFps(uint32 ssrc) { 1660 int VideoChannel::GetScreencastFps(uint32_t ssrc) {
1665 ScreencastDetailsData data(ssrc); 1661 ScreencastDetailsData data(ssrc);
1666 worker_thread()->Invoke<void>(Bind( 1662 worker_thread()->Invoke<void>(Bind(
1667 &VideoChannel::GetScreencastDetails_w, this, &data)); 1663 &VideoChannel::GetScreencastDetails_w, this, &data));
1668 return data.fps; 1664 return data.fps;
1669 } 1665 }
1670 1666
1671 int VideoChannel::GetScreencastMaxPixels(uint32 ssrc) { 1667 int VideoChannel::GetScreencastMaxPixels(uint32_t ssrc) {
1672 ScreencastDetailsData data(ssrc); 1668 ScreencastDetailsData data(ssrc);
1673 worker_thread()->Invoke<void>(Bind( 1669 worker_thread()->Invoke<void>(Bind(
1674 &VideoChannel::GetScreencastDetails_w, this, &data)); 1670 &VideoChannel::GetScreencastDetails_w, this, &data));
1675 return data.screencast_max_pixels; 1671 return data.screencast_max_pixels;
1676 } 1672 }
1677 1673
1678 bool VideoChannel::SendIntraFrame() { 1674 bool VideoChannel::SendIntraFrame() {
1679 worker_thread()->Invoke<void>(Bind( 1675 worker_thread()->Invoke<void>(Bind(
1680 &VideoMediaChannel::SendIntraFrame, media_channel())); 1676 &VideoMediaChannel::SendIntraFrame, media_channel()));
1681 return true; 1677 return true;
1682 } 1678 }
1683 1679
1684 bool VideoChannel::RequestIntraFrame() { 1680 bool VideoChannel::RequestIntraFrame() {
1685 worker_thread()->Invoke<void>(Bind( 1681 worker_thread()->Invoke<void>(Bind(
1686 &VideoMediaChannel::RequestIntraFrame, media_channel())); 1682 &VideoMediaChannel::RequestIntraFrame, media_channel()));
1687 return true; 1683 return true;
1688 } 1684 }
1689 1685
1690 bool VideoChannel::SetVideoSend(uint32 ssrc, 1686 bool VideoChannel::SetVideoSend(uint32_t ssrc,
1691 bool mute, 1687 bool mute,
1692 const VideoOptions* options) { 1688 const VideoOptions* options) {
1693 return InvokeOnWorker(Bind(&VideoMediaChannel::SetVideoSend, media_channel(), 1689 return InvokeOnWorker(Bind(&VideoMediaChannel::SetVideoSend, media_channel(),
1694 ssrc, mute, options)); 1690 ssrc, mute, options));
1695 } 1691 }
1696 1692
1697 void VideoChannel::ChangeState() { 1693 void VideoChannel::ChangeState() {
1698 // Send outgoing data if we're the active call, we have the remote content, 1694 // Send outgoing data if we're the active call, we have the remote content,
1699 // and we have had some form of connectivity. 1695 // and we have had some form of connectivity.
1700 bool send = IsReadyToSend(); 1696 bool send = IsReadyToSend();
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
1854 << it->selector.ssrc << ", '" 1850 << it->selector.ssrc << ", '"
1855 << it->selector.groupid << "', '" 1851 << it->selector.groupid << "', '"
1856 << it->selector.streamid << "'" 1852 << it->selector.streamid << "'"
1857 << ") is not in the local streams."; 1853 << ") is not in the local streams.";
1858 } 1854 }
1859 } 1855 }
1860 1856
1861 return ret; 1857 return ret;
1862 } 1858 }
1863 1859
1864 bool VideoChannel::AddScreencast_w(uint32 ssrc, VideoCapturer* capturer) { 1860 bool VideoChannel::AddScreencast_w(uint32_t ssrc, VideoCapturer* capturer) {
1865 if (screencast_capturers_.find(ssrc) != screencast_capturers_.end()) { 1861 if (screencast_capturers_.find(ssrc) != screencast_capturers_.end()) {
1866 return false; 1862 return false;
1867 } 1863 }
1868 capturer->SignalStateChange.connect(this, &VideoChannel::OnStateChange); 1864 capturer->SignalStateChange.connect(this, &VideoChannel::OnStateChange);
1869 screencast_capturers_[ssrc] = capturer; 1865 screencast_capturers_[ssrc] = capturer;
1870 return true; 1866 return true;
1871 } 1867 }
1872 1868
1873 bool VideoChannel::RemoveScreencast_w(uint32 ssrc) { 1869 bool VideoChannel::RemoveScreencast_w(uint32_t ssrc) {
1874 ScreencastMap::iterator iter = screencast_capturers_.find(ssrc); 1870 ScreencastMap::iterator iter = screencast_capturers_.find(ssrc);
1875 if (iter == screencast_capturers_.end()) { 1871 if (iter == screencast_capturers_.end()) {
1876 return false; 1872 return false;
1877 } 1873 }
1878 // Clean up VideoCapturer. 1874 // Clean up VideoCapturer.
1879 delete iter->second; 1875 delete iter->second;
1880 screencast_capturers_.erase(iter); 1876 screencast_capturers_.erase(iter);
1881 return true; 1877 return true;
1882 } 1878 }
1883 1879
1884 bool VideoChannel::IsScreencasting_w() const { 1880 bool VideoChannel::IsScreencasting_w() const {
1885 return !screencast_capturers_.empty(); 1881 return !screencast_capturers_.empty();
1886 } 1882 }
1887 1883
1888 void VideoChannel::GetScreencastDetails_w( 1884 void VideoChannel::GetScreencastDetails_w(
1889 ScreencastDetailsData* data) const { 1885 ScreencastDetailsData* data) const {
1890 ScreencastMap::const_iterator iter = screencast_capturers_.find(data->ssrc); 1886 ScreencastMap::const_iterator iter = screencast_capturers_.find(data->ssrc);
1891 if (iter == screencast_capturers_.end()) { 1887 if (iter == screencast_capturers_.end()) {
1892 return; 1888 return;
1893 } 1889 }
1894 VideoCapturer* capturer = iter->second; 1890 VideoCapturer* capturer = iter->second;
1895 const VideoFormat* video_format = capturer->GetCaptureFormat(); 1891 const VideoFormat* video_format = capturer->GetCaptureFormat();
1896 data->fps = VideoFormat::IntervalToFps(video_format->interval); 1892 data->fps = VideoFormat::IntervalToFps(video_format->interval);
1897 data->screencast_max_pixels = capturer->screencast_max_pixels(); 1893 data->screencast_max_pixels = capturer->screencast_max_pixels();
1898 } 1894 }
1899 1895
1900 void VideoChannel::OnScreencastWindowEvent_s(uint32 ssrc, 1896 void VideoChannel::OnScreencastWindowEvent_s(uint32_t ssrc,
1901 rtc::WindowEvent we) { 1897 rtc::WindowEvent we) {
1902 ASSERT(signaling_thread() == rtc::Thread::Current()); 1898 ASSERT(signaling_thread() == rtc::Thread::Current());
1903 SignalScreencastWindowEvent(ssrc, we); 1899 SignalScreencastWindowEvent(ssrc, we);
1904 } 1900 }
1905 1901
1906 void VideoChannel::OnMessage(rtc::Message *pmsg) { 1902 void VideoChannel::OnMessage(rtc::Message *pmsg) {
1907 switch (pmsg->message_id) { 1903 switch (pmsg->message_id) {
1908 case MSG_SCREENCASTWINDOWEVENT: { 1904 case MSG_SCREENCASTWINDOWEVENT: {
1909 const ScreencastEventMessageData* data = 1905 const ScreencastEventMessageData* data =
1910 static_cast<ScreencastEventMessageData*>(pmsg->pdata); 1906 static_cast<ScreencastEventMessageData*>(pmsg->pdata);
(...skipping 19 matching lines...) Expand all
1930 } 1926 }
1931 1927
1932 // TODO(pthatcher): Look into removing duplicate code between 1928 // TODO(pthatcher): Look into removing duplicate code between
1933 // audio, video, and data, perhaps by using templates. 1929 // audio, video, and data, perhaps by using templates.
1934 void VideoChannel::OnMediaMonitorUpdate( 1930 void VideoChannel::OnMediaMonitorUpdate(
1935 VideoMediaChannel* media_channel, const VideoMediaInfo &info) { 1931 VideoMediaChannel* media_channel, const VideoMediaInfo &info) {
1936 ASSERT(media_channel == this->media_channel()); 1932 ASSERT(media_channel == this->media_channel());
1937 SignalMediaMonitor(this, info); 1933 SignalMediaMonitor(this, info);
1938 } 1934 }
1939 1935
1940 void VideoChannel::OnScreencastWindowEvent(uint32 ssrc, 1936 void VideoChannel::OnScreencastWindowEvent(uint32_t ssrc,
1941 rtc::WindowEvent event) { 1937 rtc::WindowEvent event) {
1942 ScreencastEventMessageData* pdata = 1938 ScreencastEventMessageData* pdata =
1943 new ScreencastEventMessageData(ssrc, event); 1939 new ScreencastEventMessageData(ssrc, event);
1944 signaling_thread()->Post(this, MSG_SCREENCASTWINDOWEVENT, pdata); 1940 signaling_thread()->Post(this, MSG_SCREENCASTWINDOWEVENT, pdata);
1945 } 1941 }
1946 1942
1947 void VideoChannel::OnStateChange(VideoCapturer* capturer, CaptureState ev) { 1943 void VideoChannel::OnStateChange(VideoCapturer* capturer, CaptureState ev) {
1948 // Map capturer events to window events. In the future we may want to simply 1944 // Map capturer events to window events. In the future we may want to simply
1949 // pass these events up directly. 1945 // pass these events up directly.
1950 rtc::WindowEvent we; 1946 rtc::WindowEvent we;
1951 if (ev == CS_STOPPED) { 1947 if (ev == CS_STOPPED) {
1952 we = rtc::WE_CLOSE; 1948 we = rtc::WE_CLOSE;
1953 } else if (ev == CS_PAUSED) { 1949 } else if (ev == CS_PAUSED) {
1954 we = rtc::WE_MINIMIZE; 1950 we = rtc::WE_MINIMIZE;
1955 } else if (ev == CS_RUNNING && previous_we_ == rtc::WE_MINIMIZE) { 1951 } else if (ev == CS_RUNNING && previous_we_ == rtc::WE_MINIMIZE) {
1956 we = rtc::WE_RESTORE; 1952 we = rtc::WE_RESTORE;
1957 } else { 1953 } else {
1958 return; 1954 return;
1959 } 1955 }
1960 previous_we_ = we; 1956 previous_we_ = we;
1961 1957
1962 uint32 ssrc = 0; 1958 uint32_t ssrc = 0;
1963 if (!GetLocalSsrc(capturer, &ssrc)) { 1959 if (!GetLocalSsrc(capturer, &ssrc)) {
1964 return; 1960 return;
1965 } 1961 }
1966 1962
1967 OnScreencastWindowEvent(ssrc, we); 1963 OnScreencastWindowEvent(ssrc, we);
1968 } 1964 }
1969 1965
1970 bool VideoChannel::GetLocalSsrc(const VideoCapturer* capturer, uint32* ssrc) { 1966 bool VideoChannel::GetLocalSsrc(const VideoCapturer* capturer, uint32_t* ssrc) {
1971 *ssrc = 0; 1967 *ssrc = 0;
1972 for (ScreencastMap::iterator iter = screencast_capturers_.begin(); 1968 for (ScreencastMap::iterator iter = screencast_capturers_.begin();
1973 iter != screencast_capturers_.end(); ++iter) { 1969 iter != screencast_capturers_.end(); ++iter) {
1974 if (iter->second == capturer) { 1970 if (iter->second == capturer) {
1975 *ssrc = iter->first; 1971 *ssrc = iter->first;
1976 return true; 1972 return true;
1977 } 1973 }
1978 } 1974 }
1979 return false; 1975 return false;
1980 } 1976 }
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
2219 delete data; 2215 delete data;
2220 break; 2216 break;
2221 } 2217 }
2222 case MSG_CHANNEL_ERROR: { 2218 case MSG_CHANNEL_ERROR: {
2223 const DataChannelErrorMessageData* data = 2219 const DataChannelErrorMessageData* data =
2224 static_cast<DataChannelErrorMessageData*>(pmsg->pdata); 2220 static_cast<DataChannelErrorMessageData*>(pmsg->pdata);
2225 delete data; 2221 delete data;
2226 break; 2222 break;
2227 } 2223 }
2228 case MSG_STREAMCLOSEDREMOTELY: { 2224 case MSG_STREAMCLOSEDREMOTELY: {
2229 rtc::TypedMessageData<uint32>* data = 2225 rtc::TypedMessageData<uint32_t>* data =
2230 static_cast<rtc::TypedMessageData<uint32>*>(pmsg->pdata); 2226 static_cast<rtc::TypedMessageData<uint32_t>*>(pmsg->pdata);
2231 SignalStreamClosedRemotely(data->data()); 2227 SignalStreamClosedRemotely(data->data());
2232 delete data; 2228 delete data;
2233 break; 2229 break;
2234 } 2230 }
2235 default: 2231 default:
2236 BaseChannel::OnMessage(pmsg); 2232 BaseChannel::OnMessage(pmsg);
2237 break; 2233 break;
2238 } 2234 }
2239 } 2235 }
2240 2236
(...skipping 24 matching lines...) Expand all
2265 SignalMediaMonitor(this, info); 2261 SignalMediaMonitor(this, info);
2266 } 2262 }
2267 2263
2268 void DataChannel::OnDataReceived( 2264 void DataChannel::OnDataReceived(
2269 const ReceiveDataParams& params, const char* data, size_t len) { 2265 const ReceiveDataParams& params, const char* data, size_t len) {
2270 DataReceivedMessageData* msg = new DataReceivedMessageData( 2266 DataReceivedMessageData* msg = new DataReceivedMessageData(
2271 params, data, len); 2267 params, data, len);
2272 signaling_thread()->Post(this, MSG_DATARECEIVED, msg); 2268 signaling_thread()->Post(this, MSG_DATARECEIVED, msg);
2273 } 2269 }
2274 2270
2275 void DataChannel::OnDataChannelError( 2271 void DataChannel::OnDataChannelError(uint32_t ssrc,
2276 uint32 ssrc, DataMediaChannel::Error err) { 2272 DataMediaChannel::Error err) {
2277 DataChannelErrorMessageData* data = new DataChannelErrorMessageData( 2273 DataChannelErrorMessageData* data = new DataChannelErrorMessageData(
2278 ssrc, err); 2274 ssrc, err);
2279 signaling_thread()->Post(this, MSG_CHANNEL_ERROR, data); 2275 signaling_thread()->Post(this, MSG_CHANNEL_ERROR, data);
2280 } 2276 }
2281 2277
2282 void DataChannel::OnDataChannelReadyToSend(bool writable) { 2278 void DataChannel::OnDataChannelReadyToSend(bool writable) {
2283 // This is usded for congestion control to indicate that the stream is ready 2279 // This is usded for congestion control to indicate that the stream is ready
2284 // to send by the MediaChannel, as opposed to OnReadyToSend, which indicates 2280 // to send by the MediaChannel, as opposed to OnReadyToSend, which indicates
2285 // that the transport channel is ready. 2281 // that the transport channel is ready.
2286 signaling_thread()->Post(this, MSG_READYTOSENDDATA, 2282 signaling_thread()->Post(this, MSG_READYTOSENDDATA,
2287 new DataChannelReadyToSendMessageData(writable)); 2283 new DataChannelReadyToSendMessageData(writable));
2288 } 2284 }
2289 2285
2290 void DataChannel::GetSrtpCryptoSuiteNames( 2286 void DataChannel::GetSrtpCryptoSuiteNames(
2291 std::vector<std::string>* ciphers) const { 2287 std::vector<std::string>* ciphers) const {
2292 GetSupportedDataCryptoSuites(ciphers); 2288 GetSupportedDataCryptoSuites(ciphers);
2293 } 2289 }
2294 2290
2295 bool DataChannel::ShouldSetupDtlsSrtp() const { 2291 bool DataChannel::ShouldSetupDtlsSrtp() const {
2296 return (data_channel_type_ == DCT_RTP); 2292 return (data_channel_type_ == DCT_RTP);
2297 } 2293 }
2298 2294
2299 void DataChannel::OnStreamClosedRemotely(uint32 sid) { 2295 void DataChannel::OnStreamClosedRemotely(uint32_t sid) {
2300 rtc::TypedMessageData<uint32>* message = 2296 rtc::TypedMessageData<uint32_t>* message =
2301 new rtc::TypedMessageData<uint32>(sid); 2297 new rtc::TypedMessageData<uint32_t>(sid);
2302 signaling_thread()->Post(this, MSG_STREAMCLOSEDREMOTELY, message); 2298 signaling_thread()->Post(this, MSG_STREAMCLOSEDREMOTELY, message);
2303 } 2299 }
2304 2300
2305 } // namespace cricket 2301 } // namespace cricket
OLDNEW
« no previous file with comments | « talk/session/media/channel.h ('k') | talk/session/media/channel_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698