result.reserve(supported_resolutions.size() * supported_formats.size());
for (auto format : supported_formats) {
for (const auto resolution : supported_resolutions) {
- float max_framerate =
- GetMaxSupportedFramerate(handle_.get(), format, resolution);
- if (max_framerate == 0.0f) {
- continue;
+ for (const auto framerate :
+ GetSupportedFramerates(handle_.get(), format, resolution)) {
+ TIZEN_MEDIA_LOG(INFO)
+ << "Supported format: " << resolution.ToString()
+ << ", framerate: " << framerate << ", pixel format: " << format;
+ result.emplace_back(
+ CameraSupportedFormat{format, framerate, resolution});
}
-
- TIZEN_MEDIA_LOG(INFO)
- << "Supported format: " << resolution.ToString()
- << ", framerate: " << max_framerate << ", pixel format: " << format;
- result.emplace_back(
- CameraSupportedFormat{format, max_framerate, resolution});
}
}
supported_formats_ = result;
}
bool SupportedFpsCb(camera_attr_fps_e fps, void* user_data) {
- float* current_max = reinterpret_cast<float*>(user_data);
- float framerate = static_cast<float>(static_cast<int>(fps));
- if (framerate > *current_max) {
- *current_max = framerate;
- }
+ std::vector<float>* result = reinterpret_cast<std::vector<float>*>(user_data);
+ result->push_back(static_cast<float>(static_cast<int>(fps)));
return true;
}
return result;
}
-float GetMaxSupportedFramerate(camera_h handle,
- camera_pixel_format_e format,
- gfx::Size resolution) {
+std::vector<float> GetSupportedFramerates(camera_h handle,
+ camera_pixel_format_e format,
+ gfx::Size resolution) {
if (!handle) {
TIZEN_MEDIA_LOG_NO_INSTANCE(ERROR) << "Invalid camera handle!";
- return 0.0f;
+ return {};
}
- // TODO(j.gajownik2) Add workaround for MJPEG
-
- float max_framerate = 0.0f;
- // TODO(j.gajownik2) What we should do with CAMERA_ATTR_FPS_AUTO?
- int err = camera_attr_foreach_supported_fps(handle, &SupportedFpsCb,
- &max_framerate);
+ std::vector<float> framerate;
+ int err = camera_attr_foreach_supported_fps_by_resolution(
+ handle, resolution.width(), resolution.height(), &SupportedFpsCb,
+ &framerate);
if (err != CAMERA_ERROR_NONE) {
TIZEN_MEDIA_LOG_NO_INSTANCE(ERROR)
<< "Error getting supported framerate: " << err;
- return 0.0f;
+ return {};
}
- return max_framerate;
+ return framerate;
}
} // namespace media
using SupportedFormats = std::vector<camera_pixel_format_e>;
SupportedFormats GetSupportedPreviewFormats(camera_h handle);
-float GetMaxSupportedFramerate(camera_h handle,
- camera_pixel_format_e format,
- gfx::Size resolution);
+std::vector<float> GetSupportedFramerates(camera_h handle,
+ camera_pixel_format_e format,
+ gfx::Size resolution);
} // namespace media