namespace {
+enum { kMaxWidth = 1280 };
+enum { kMaxHeight = 720 };
+enum { kMaxFramerate = 30 };
+
media::VideoPixelFormat toChromiumType(camera_pixel_format_e e) {
switch (e) {
case CAMERA_PIXEL_FORMAT_NV12:
std::vector<gfx::Size>* sizes =
static_cast< std::vector<gfx::Size>* >(user_data);
DCHECK(sizes);
+
+ if ((width > kMaxWidth && height > kMaxHeight) ||
+ (height > kMaxWidth && width > kMaxHeight)) {
+ return true;
+ }
+
sizes->push_back(gfx::Size(width, height));
return true;
bool OnCameraSupportedFPS(camera_attr_fps_e fps, void* user_data) {
std::vector<int>* list_fps = static_cast< std::vector<int>* >(user_data);
DCHECK(list_fps);
- if (CAMERA_ATTR_FPS_AUTO != fps) {
+ if (CAMERA_ATTR_FPS_AUTO != fps && kMaxFramerate >= fps) {
// AUTO format is not defined on Chromium, so skip.
list_fps->push_back(static_cast<int>(fps));
}
format.frame_rate = *itrFPS;
format.pixel_format = *itrFMT;
outSupportedFormats.push_back(format);
+
+ LOG(INFO) << __FUNCTION__
+ << " frame_size:" << format.frame_size.width() << "X" << format.frame_size.height()
+ << " frame_rate:" << format.frame_rate
+ << " pixel_format:" << format.pixel_format;
}
}
}
device_count = 0;
LOG(ERROR) << "Cannot read camera count";
}
-
return device_count;
}
enum { kMjpegWidth = 640 };
enum { kMjpegHeight = 480 };
enum { kTypicalFramerate = 30 };
-enum { kTypicalFormat = CAMERA_PIXEL_FORMAT_NV12 };
camera_pixel_format_e toCapiType(media::VideoPixelFormat e) {
switch (e) {
return CAMERA_PIXEL_FORMAT_INVALID;
}
+libyuv::FourCC toLibYUVtype(camera_pixel_format_e e) {
+ switch (e) {
+ case CAMERA_PIXEL_FORMAT_NV12:
+ return libyuv::FOURCC_NV12;
+ case CAMERA_PIXEL_FORMAT_NV21:
+ return libyuv::FOURCC_NV21;
+ case CAMERA_PIXEL_FORMAT_YUYV:
+ return libyuv::FOURCC_YUYV;
+ case CAMERA_PIXEL_FORMAT_UYVY:
+ return libyuv::FOURCC_UYVY;
+ case CAMERA_PIXEL_FORMAT_I420:
+ return libyuv::FOURCC_I420;
+ case CAMERA_PIXEL_FORMAT_YV12:
+ return libyuv::FOURCC_YV12;
+ default:
+ NOTREACHED();
+ }
+ return libyuv::FOURCC_ANY;
+}
+
+bool OnPreviewFormat(
+ camera_pixel_format_e format, void* user_data) {
+ std::vector<camera_pixel_format_e>* list_format =
+ static_cast< std::vector<camera_pixel_format_e>* >(user_data);
+ DCHECK(list_format);
+
+ list_format->push_back(format);
+
+ return true;
+}
+
} // unnamed namespace
namespace media {
void VideoCaptureDeviceTizen::OnCameraCaptured(camera_preview_data_s* frame,
void* data) {
- if ( frame->format != CAMERA_PIXEL_FORMAT_NV12 ) {
- NOTIMPLEMENTED();
- return;
- }
-
VideoCaptureDeviceTizen* self = static_cast<VideoCaptureDeviceTizen*>(data);
camera_attr_fps_e current_fps =
static_cast<camera_attr_fps_e>(kTypicalFramerate);
camera_attr_get_preview_fps(self->camera_, ¤t_fps);
-
int destination_width = frame->width;
int destination_height = frame->height;
frame->width, frame->height,
frame->width, frame->height,
rotation_mode,
- libyuv::FOURCC_NV12);
+ toLibYUVtype(frame->format));
VideoCaptureFormat capture_format_;
capture_format_.frame_size.SetSize(destination_width, destination_height);
int frame_rate,
VideoPixelFormat format,
scoped_ptr<Client> client) {
+ DVLOG(1) << __FUNCTION__
+ << " width:" << width
+ << " height:" << height
+ << " frame_rate:" << frame_rate
+ << " format:" << format;
+
DCHECK_EQ(worker_.message_loop(), base::MessageLoop::current());
client_ = client.Pass();
if (CAMERA_ERROR_NONE !=
camera_set_preview_resolution(camera_, width, height)) {
- LOG(WARNING) << "Camera does not support "
- << width << " x " << height << " resolution.";
LOG(WARNING) << "trying default resolution: "
<< kMjpegWidth << " x " << kMjpegHeight;
+
if (CAMERA_ERROR_NONE !=
camera_set_preview_resolution(camera_, kMjpegWidth, kMjpegHeight)) {
+ LOG(ERROR) << "fail to try default resolution: "
+ << kMjpegWidth << " x " << kMjpegHeight;
SetErrorState("Camera internal Error");
return;
}
if (CAMERA_ERROR_NONE !=
camera_set_preview_format(camera_, toCapiType(format))) {
- LOG(WARNING) << "Camera does not support file format :"
- << toCapiType(format);
- LOG(WARNING) << "trying default format: " << kTypicalFormat;
- if (CAMERA_ERROR_NONE != camera_set_preview_format(
- camera_, (camera_pixel_format_e)kTypicalFormat)) {
+ std::vector<camera_pixel_format_e> supported_formats;
+ if (CAMERA_ERROR_NONE !=
+ camera_foreach_supported_preview_format(
+ camera_, OnPreviewFormat, &supported_formats)) {
+ LOG(ERROR) << "Cannot get the supported formats for camera";
+ SetErrorState("Camera internal Error");
+ return;
+ }
+ if (supported_formats.empty()) {
+ LOG(ERROR) << "Cannot get the supported formats for camera";
+ SetErrorState("Camera internal Error");
+ return;
+ }
+ if (CAMERA_ERROR_NONE !=
+ camera_set_preview_format(camera_, supported_formats[0])) {
+ LOG(ERROR) << "fail to set preview format: " << supported_formats[0];
SetErrorState("Camera internal Error");
return;
}
}
if (CAMERA_ERROR_NONE !=
- camera_attr_set_preview_fps(camera_, (camera_attr_fps_e)frame_rate)) {
+ camera_attr_set_preview_fps(
+ camera_, static_cast<camera_attr_fps_e>(frame_rate))) {
LOG(WARNING) << "Camera does not support frame rate:" << frame_rate;
LOG(WARNING) << "trying default frame rate: " << kTypicalFramerate;
if (CAMERA_ERROR_NONE !=
- camera_attr_set_preview_fps(camera_,
- (camera_attr_fps_e)kTypicalFramerate)) {
+ camera_attr_set_preview_fps(
+ camera_, static_cast<camera_attr_fps_e>(kTypicalFramerate))) {
SetErrorState("Camera internal Error");
return;
}