diff options
author | jiayl@chromium.org <jiayl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-08 20:24:13 +0000 |
---|---|---|
committer | jiayl@chromium.org <jiayl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-08 20:24:13 +0000 |
commit | 2bc265237cba80abbd29c4b8a39d2fe060d80e7e (patch) | |
tree | 86194e8f57af3971dc35c76dbd39281faaf03c4a /content/browser/resources | |
parent | 2170b864600ad6902296a93de178f6b03f4cbb5e (diff) | |
download | chromium_src-2bc265237cba80abbd29c4b8a39d2fe060d80e7e.zip chromium_src-2bc265237cba80abbd29c4b8a39d2fe060d80e7e.tar.gz chromium_src-2bc265237cba80abbd29c4b8a39d2fe060d80e7e.tar.bz2 |
Fix the way we get ssrc from an ssrc report for the coming changes in getStats, i.e. report.id is no longer the ssrc id, which is now in the name-value pairs.
BUG=
Review URL: https://chromiumcodereview.appspot.com/15000002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@198976 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/resources')
4 files changed, 61 insertions, 28 deletions
diff --git a/content/browser/resources/media/ssrc_info_manager.js b/content/browser/resources/media/ssrc_info_manager.js index 8236e87..bb99f81 100644 --- a/content/browser/resources/media/ssrc_info_manager.js +++ b/content/browser/resources/media/ssrc_info_manager.js @@ -3,6 +3,39 @@ // found in the LICENSE file. + +/** + * Get the ssrc if |report| is an ssrc report. + * + * @param {!Object} report The object contains id, type, and stats, where stats + * is the object containing timestamp and values, which is an array of + * strings, whose even index entry is the name of the stat, and the odd + * index entry is the value. + * @return {?string} The ssrc. + */ +function GetSsrcFromReport(report) { + if (report.type != 'ssrc') { + console.warn("Trying to get ssrc from non-ssrc report."); + return null; + } + + // If the 'ssrc' name-value pair exists, return the value; otherwise, return + // the report id. + // The 'ssrc' name-value pair only exists in an upcoming Libjingle change. Old + // versions use id to refer to the ssrc. + // + // TODO(jiayl): remove the fallback to id once the Libjingle change is rolled + // to Chrome. + if (report.stats && report.stats.values) { + for (var i = 0; i < report.stats.values.length - 1; i += 2) { + if (report.stats.values[i] == 'ssrc') { + return report.stats.values[i + 1]; + } + } + } + return report.id; +}; + /** * SsrcInfoManager stores the ssrc stream info extracted from SDP. */ @@ -48,9 +81,8 @@ var SsrcInfoManager = (function() { * The className of the ssrc info parent element. * @type {string} * @const - * @private */ - this.SSRC_INFO_BLOCK_CLASS_ = 'ssrc-info-block'; + this.SSRC_INFO_BLOCK_CLASS = 'ssrc-info-block'; } SsrcInfoManager.prototype = { @@ -118,7 +150,7 @@ var SsrcInfoManager = (function() { if (!this.streamInfoContainer_[ssrc]) return; - parentElement.className = this.SSRC_INFO_BLOCK_CLASS_; + parentElement.className = this.SSRC_INFO_BLOCK_CLASS; var fieldElement; for (var property in this.streamInfoContainer_[ssrc]) { diff --git a/content/browser/resources/media/stats_graph_helper.js b/content/browser/resources/media/stats_graph_helper.js index c252f0a..33146f9 100644 --- a/content/browser/resources/media/stats_graph_helper.js +++ b/content/browser/resources/media/stats_graph_helper.js @@ -82,17 +82,19 @@ var dataConversionConfig = { var graphViews = {}; var dataSeries = {}; -// Adds the stats report |singleReport| to the timeline graph for the given -// |peerConnectionElement| and |reportName|. -function drawSingleReport( - peerConnectionElement, reportType, reportId, singleReport) { - if (!singleReport || !singleReport.values) +// Adds the stats report |report| to the timeline graph for the given +// |peerConnectionElement|. +function drawSingleReport(peerConnectionElement, report) { + var reportType = report.type; + var reportId = report.id; + var stats = report.stats; + if (!stats || !stats.values) return; var reportName = reportType + '-' + reportId; - for (var i = 0; i < singleReport.values.length - 1; i = i + 2) { - var rawLabel = singleReport.values[i]; - var rawValue = parseInt(singleReport.values[i + 1]); + for (var i = 0; i < stats.values.length - 1; i = i + 2) { + var rawLabel = stats.values[i]; + var rawValue = parseInt(stats.values[i + 1]); if (isNaN(rawValue)) return; @@ -105,7 +107,7 @@ function drawSingleReport( // We need to convert the value if dataConversionConfig[rawLabel] exists. if (dataConversionConfig[rawLabel]) { // Updates the original dataSeries before the conversion. - addDataSeriesPoint(rawDataSeriesId, singleReport.timestamp, + addDataSeriesPoint(rawDataSeriesId, stats.timestamp, rawLabel, rawValue); // Convert to another value to draw on graph, using the original @@ -119,7 +121,7 @@ function drawSingleReport( // Updates the final dataSeries to draw. addDataSeriesPoint( - finalDataSeriesId, singleReport.timestamp, finalLabel, finalValue); + finalDataSeriesId, stats.timestamp, finalLabel, finalValue); // Updates the graph. var graphType = bweCompoundGraphConfig[finalLabel] ? @@ -129,9 +131,9 @@ function drawSingleReport( if (!graphViews[graphViewId]) { graphViews[graphViewId] = createStatsGraphView(peerConnectionElement, - reportType, reportId, + report, graphType); - var date = new Date(singleReport.timestamp); + var date = new Date(stats.timestamp); graphViews[graphViewId].setDateRange(date, date); } // Adds the new dataSeries to the graphView. We have to do it here to cover @@ -157,10 +159,9 @@ function addDataSeriesPoint(dataSeriesId, time, label, value) { // Ensures a div container to hold all stats graphs for one track is created as // a child of |peerConnectionElement|. -function ensureStatsGraphTopContainer( - peerConnectionElement, reportType, reportId) { +function ensureStatsGraphTopContainer(peerConnectionElement, report) { var containerId = peerConnectionElement.id + '-' + - reportType + '-' + reportId + '-graph-container'; + report.type + '-' + report.id + '-graph-container'; var container = $(containerId); if (!container) { container = document.createElement('details'); @@ -172,12 +173,13 @@ function ensureStatsGraphTopContainer( container.firstChild.firstChild.className = STATS_GRAPH_CONTAINER_HEADING_CLASS; container.firstChild.firstChild.textContent = - 'Stats graphs for ' + reportType + '-' + reportId; + 'Stats graphs for ' + report.type + '-' + report.id; - if (reportType == 'ssrc') { + if (report.type == 'ssrc') { var ssrcInfoElement = document.createElement('div'); container.firstChild.appendChild(ssrcInfoElement); - ssrcInfoManager.populateSsrcInfo(ssrcInfoElement, reportId); + ssrcInfoManager.populateSsrcInfo(ssrcInfoElement, + GetSsrcFromReport(report)); } } return container; @@ -186,12 +188,12 @@ function ensureStatsGraphTopContainer( // Creates the container elements holding a timeline graph // and the TimelineGraphView object. function createStatsGraphView( - peerConnectionElement, reportType, reportId, statsName) { + peerConnectionElement, report, statsName) { var topContainer = ensureStatsGraphTopContainer(peerConnectionElement, - reportType, reportId); + report); var graphViewId = peerConnectionElement.id + '-' + - reportType + '-' + reportId + '-' + statsName; + report.type + '-' + report.id + '-' + statsName; var divId = graphViewId + '-div'; var canvasId = graphViewId + '-canvas'; var container = document.createElement("div"); @@ -203,7 +205,7 @@ function createStatsGraphView( if (statsName == 'bweCompound') { container.insertBefore( createBweCompoundLegend( - peerConnectionElement, reportType + '-' + reportId), + peerConnectionElement, report.type + '-' + report.id), $(divId)); } return new TimelineGraphView(divId, canvasId); diff --git a/content/browser/resources/media/stats_table.js b/content/browser/resources/media/stats_table.js index d31c73a..c72af11 100644 --- a/content/browser/resources/media/stats_table.js +++ b/content/browser/resources/media/stats_table.js @@ -91,7 +91,7 @@ var StatsTable = (function(ssrcInfoManager) { table.insertRow(1); table.rows[1].innerHTML = '<td colspan=2></td>'; this.ssrcInfoManager_.populateSsrcInfo( - table.rows[1].cells[0], report.id); + table.rows[1].cells[0], GetSsrcFromReport(report)); } } return table; diff --git a/content/browser/resources/media/webrtc_internals.js b/content/browser/resources/media/webrtc_internals.js index 1fa0faf..4cef1a4 100644 --- a/content/browser/resources/media/webrtc_internals.js +++ b/content/browser/resources/media/webrtc_internals.js @@ -157,8 +157,7 @@ function addStats(data) { for (var i = 0; i < data.reports.length; ++i) { var report = data.reports[i]; statsTable.addStatsReport(peerConnectionElement, report); - drawSingleReport(peerConnectionElement, - report.type, report.id, report.stats); + drawSingleReport(peerConnectionElement, report); } } |