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

Side by Side Diff: media/video/capture/linux/video_capture_device_linux.cc

Issue 12767006: [Cleanup] Remove StringPrintf from global namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase, once more Created 7 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/video/capture/linux/video_capture_device_linux.h" 5 #include "media/video/capture/linux/video_capture_device_linux.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #if defined(OS_OPENBSD) 9 #if defined(OS_OPENBSD)
10 #include <sys/videoio.h> 10 #include <sys/videoio.h>
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 // Failed to open this device. 119 // Failed to open this device.
120 continue; 120 continue;
121 } 121 }
122 // Test if this is a V4L2 capture device. 122 // Test if this is a V4L2 capture device.
123 v4l2_capability cap; 123 v4l2_capability cap;
124 if ((ioctl(fd, VIDIOC_QUERYCAP, &cap) == 0) && 124 if ((ioctl(fd, VIDIOC_QUERYCAP, &cap) == 0) &&
125 (cap.capabilities & V4L2_CAP_VIDEO_CAPTURE) && 125 (cap.capabilities & V4L2_CAP_VIDEO_CAPTURE) &&
126 !(cap.capabilities & V4L2_CAP_VIDEO_OUTPUT)) { 126 !(cap.capabilities & V4L2_CAP_VIDEO_OUTPUT)) {
127 // This is a V4L2 video capture device 127 // This is a V4L2 video capture device
128 if (HasUsableFormats(fd)) { 128 if (HasUsableFormats(fd)) {
129 name.device_name = StringPrintf("%s", cap.card); 129 name.device_name = base::StringPrintf("%s", cap.card);
130 device_names->push_back(name); 130 device_names->push_back(name);
131 } else { 131 } else {
132 DVLOG(1) << "No usable formats reported by " << info.filename; 132 DVLOG(1) << "No usable formats reported by " << info.filename;
133 } 133 }
134 } 134 }
135 close(fd); 135 close(fd);
136 } 136 }
137 } 137 }
138 138
139 VideoCaptureDevice* VideoCaptureDevice::Create(const Name& device_name) { 139 VideoCaptureDevice* VideoCaptureDevice::Create(const Name& device_name) {
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 411 buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
412 buffer.memory = V4L2_MEMORY_MMAP; 412 buffer.memory = V4L2_MEMORY_MMAP;
413 // Dequeue a buffer. 413 // Dequeue a buffer.
414 if (ioctl(device_fd_, VIDIOC_DQBUF, &buffer) == 0) { 414 if (ioctl(device_fd_, VIDIOC_DQBUF, &buffer) == 0) {
415 observer_->OnIncomingCapturedFrame( 415 observer_->OnIncomingCapturedFrame(
416 static_cast<uint8*> (buffer_pool_[buffer.index].start), 416 static_cast<uint8*> (buffer_pool_[buffer.index].start),
417 buffer.bytesused, base::Time::Now(), 0, false, false); 417 buffer.bytesused, base::Time::Now(), 0, false, false);
418 418
419 // Enqueue the buffer again. 419 // Enqueue the buffer again.
420 if (ioctl(device_fd_, VIDIOC_QBUF, &buffer) == -1) { 420 if (ioctl(device_fd_, VIDIOC_QBUF, &buffer) == -1) {
421 SetErrorState( 421 SetErrorState(base::StringPrintf(
422 StringPrintf("Failed to enqueue capture buffer errno %d", errno)); 422 "Failed to enqueue capture buffer errno %d", errno));
423 } 423 }
424 } // Else wait for next event. 424 } // Else wait for next event.
425 } 425 }
426 426
427 v4l2_thread_.message_loop()->PostTask( 427 v4l2_thread_.message_loop()->PostTask(
428 FROM_HERE, 428 FROM_HERE,
429 base::Bind(&VideoCaptureDeviceLinux::OnCaptureTask, 429 base::Bind(&VideoCaptureDeviceLinux::OnCaptureTask,
430 base::Unretained(this))); 430 base::Unretained(this)));
431 } 431 }
432 432
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 buffer_pool_size_ = 0; 498 buffer_pool_size_ = 0;
499 } 499 }
500 500
501 void VideoCaptureDeviceLinux::SetErrorState(const std::string& reason) { 501 void VideoCaptureDeviceLinux::SetErrorState(const std::string& reason) {
502 DVLOG(1) << reason; 502 DVLOG(1) << reason;
503 state_ = kError; 503 state_ = kError;
504 observer_->OnError(); 504 observer_->OnError();
505 } 505 }
506 506
507 } // namespace media 507 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698