Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
[Windows] M48 fixup for the Support RealSense Cameras patch
Browse files Browse the repository at this point in the history
BUG=XWALK-6189
  • Loading branch information
huningxin authored and Olli Raula committed Feb 4, 2016
1 parent 2afaca7 commit b48bbd8
Showing 1 changed file with 23 additions and 16 deletions.
39 changes: 23 additions & 16 deletions media/capture/video/win/video_capture_device_rs_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,33 +21,33 @@ namespace media {
// Map of color pixel formats of PXCImage::PixelFormat to Chromium ones.
static const struct {
PXCImage::PixelFormat pxc_format;
VideoCapturePixelFormat chromium_format;
VideoPixelFormat chromium_format;
} pixel_formats[] = {
{PXCImage::PIXEL_FORMAT_RGB24, VIDEO_CAPTURE_PIXEL_FORMAT_RGB24},
{PXCImage::PIXEL_FORMAT_RGB32, VIDEO_CAPTURE_PIXEL_FORMAT_ARGB},
{PXCImage::PIXEL_FORMAT_NV12, VIDEO_CAPTURE_PIXEL_FORMAT_NV12},
{PXCImage::PIXEL_FORMAT_YUY2, VIDEO_CAPTURE_PIXEL_FORMAT_YUY2}
{PXCImage::PIXEL_FORMAT_RGB24, PIXEL_FORMAT_RGB24},
{PXCImage::PIXEL_FORMAT_RGB32, PIXEL_FORMAT_ARGB},
{PXCImage::PIXEL_FORMAT_NV12, PIXEL_FORMAT_NV12},
{PXCImage::PIXEL_FORMAT_YUY2, PIXEL_FORMAT_YUY2}
};

static VideoCapturePixelFormat PixelFormatPxcToChromium(
static VideoPixelFormat PixelFormatPxcToChromium(
const PXCImage::PixelFormat pxc_format) {
for (size_t i = 0; i < arraysize(pixel_formats); ++i) {
if (pxc_format == pixel_formats[i].pxc_format)
return pixel_formats[i].chromium_format;
}
DLOG(ERROR) << "Device supports an unknown media type of Chromium "
<< PXCImage::PixelFormatToString(pxc_format);
return VIDEO_CAPTURE_PIXEL_FORMAT_UNKNOWN;
return PIXEL_FORMAT_UNKNOWN;
}

static PXCImage::PixelFormat PixelFormatChromiumToPxc(
const VideoCapturePixelFormat chromium_format) {
const VideoPixelFormat chromium_format) {
for (size_t i = 0; i < arraysize(pixel_formats); ++i) {
if (chromium_format == pixel_formats[i].chromium_format)
return pixel_formats[i].pxc_format;
}
DLOG(ERROR) << "Chromium requests an unknown media type of device "
<< VideoCaptureFormat::PixelFormatToString(chromium_format);
<< VideoPixelFormatToString(chromium_format);
return PXCImage::PIXEL_FORMAT_ANY;
}

Expand Down Expand Up @@ -177,14 +177,21 @@ bool VideoCaptureDeviceRSWin::Init() {
for (int profile_index = 0; profile_index < num_profiles; ++profile_index) {
PXCCapture::Device::StreamProfileSet profile_set = {};
if (PXC_FAILED(capture_device_->QueryStreamProfileSet(
PXCCapture::STREAM_TYPE_COLOR, profile_index, &profile_set)))
PXCCapture::STREAM_TYPE_COLOR, profile_index, &profile_set)))
break;
PXCCapture::Device::StreamProfile profile = profile_set.color;
if ((profile.imageInfo.format != PXCImage::PIXEL_FORMAT_RGB32) ||
(profile.options &
PXCCapture::Device::StreamOption::STREAM_OPTION_UNRECTIFIED)) {
// Only support RGB32 and rectified streams.
continue;
}
DVLOG(1) << "Profile[" << profile_index << "]: "
<< PXCImage::PixelFormatToString(profile_set.color.imageInfo.format)
<< " (" << profile_set.color.imageInfo.width << "x"
<< profile_set.color.imageInfo.height << ")"
<< " @" << profile_set.color.frameRate.max << "fps";
profiles_.push_back(profile_set.color);
<< PXCImage::PixelFormatToString(profile.imageInfo.format)
<< " (" << profile.imageInfo.width << "x"
<< profile.imageInfo.height << ")"
<< " @" << profile.frameRate.max << "fps";
profiles_.push_back(profile);
}
return true;
}
Expand Down Expand Up @@ -334,7 +341,7 @@ bool VideoCaptureDeviceRSWin::OnNewSample(PXCCapture::Sample* sample) {

void VideoCaptureDeviceRSWin::SetErrorState(const std::string& reason) {
DVLOG(1) << reason;
client_->OnError(reason);
client_->OnError(FROM_HERE, reason);
}

bool VideoCaptureDeviceRSWin::CompareProfile(
Expand Down

0 comments on commit b48bbd8

Please sign in to comment.