Skip to content

Commit

Permalink
Add UMA stats for starting and stopping video capture.
Browse files Browse the repository at this point in the history
It
* logs whenever we try to start capture for a client.
* logs the stop reason when we stop capture for a client (normal or due to an error).

Stop capture due to an error can happen when opening the device (async operation), during the session, or when closing down.

BUG=399835

Review URL: https://codereview.chromium.org/464383002

Cr-Commit-Position: refs/heads/master@{#289789}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@289789 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
grunell@chromium.org committed Aug 15, 2014
1 parent e9064aa commit 5c7a919
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
22 changes: 22 additions & 0 deletions content/browser/renderer_host/media/video_capture_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,22 @@ void ConsolidateCaptureFormats(media::VideoCaptureFormats* formats) {
const int kMaxNumberOfBuffers = 3;
const int kMaxNumberOfBuffersForTabCapture = 5;

// Used for logging capture events.
// Elements in this enum should not be deleted or rearranged; the only
// permitted operation is to add new elements before NUM_VIDEO_CAPTURE_EVENT.
enum VideoCaptureEvent {
VIDEO_CAPTURE_EVENT_START_CAPTURE = 0,
VIDEO_CAPTURE_EVENT_STOP_CAPTURE_NORMAL = 1,
VIDEO_CAPTURE_EVENT_STOP_CAPTURE_DUE_TO_ERROR = 2,
NUM_VIDEO_CAPTURE_EVENT
};

void LogVideoCaptureEvent(VideoCaptureEvent event) {
UMA_HISTOGRAM_ENUMERATION("Media.VideoCaptureManager.Event",
event,
NUM_VIDEO_CAPTURE_EVENT);
}

} // namespace

namespace content {
Expand Down Expand Up @@ -287,6 +303,8 @@ void VideoCaptureManager::StartCaptureForClient(

DCHECK(entry->video_capture_controller);

LogVideoCaptureEvent(VIDEO_CAPTURE_EVENT_START_CAPTURE);

// First client starts the device.
if (entry->video_capture_controller->GetClientCount() == 0) {
DVLOG(1) << "VideoCaptureManager starting device (type = "
Expand Down Expand Up @@ -317,6 +335,10 @@ void VideoCaptureManager::StopCaptureForClient(
DCHECK(controller);
DCHECK(client_handler);

LogVideoCaptureEvent(aborted_due_to_error ?
VIDEO_CAPTURE_EVENT_STOP_CAPTURE_DUE_TO_ERROR :
VIDEO_CAPTURE_EVENT_STOP_CAPTURE_NORMAL);

DeviceEntry* entry = GetDeviceEntryForController(controller);
if (!entry) {
NOTREACHED();
Expand Down
12 changes: 12 additions & 0 deletions tools/metrics/histograms/histograms.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11430,6 +11430,12 @@ Therefore, the affected-histogram name has to have at least one dot in it.
<summary>Measures the time taken for VideoCaptureManager::</summary>
</histogram>

<histogram name="Media.VideoCaptureManager.Event" enum="VideoCaptureEvent">
<owner>grunell@chromium.org</owner>
<owner>mcasas@chromium.org</owner>
<summary>Counts video capture event, such as start and stop capture.</summary>
</histogram>

<histogram name="Media.VideoCodec" enum="VideoCodec">
<owner>scherkus@chromium.org</owner>
<summary>Video codec used in HTML5 media.</summary>
Expand Down Expand Up @@ -50150,6 +50156,12 @@ Therefore, the affected-histogram name has to have at least one dot in it.
<int value="0" label="VAAPI_ERROR"/>
</enum>

<enum name="VideoCaptureEvent" type="int">
<int value="0" label="Starting video capture"/>
<int value="1" label="Stopping video capture normally"/>
<int value="2" label="Stopping video capture due to error"/>
</enum>

<enum name="VideoCodec" type="int">
<int value="0" label="kUnknownVideoCodec"/>
<int value="1" label="kCodecH264"/>
Expand Down

0 comments on commit 5c7a919

Please sign in to comment.