constexpr int kMaxIso = 3200;
constexpr int kStepIso = 50;
+int CameraRotaionToInt(camera_rotation_e rotation) {
+ switch (rotation) {
+ case CAMERA_ROTATION_NONE:
+ return 0;
+ case CAMERA_ROTATION_90:
+ return 90;
+ case CAMERA_ROTATION_180:
+ return 180;
+ case CAMERA_ROTATION_270:
+ return 270;
+ }
+ NOTREACHED();
+ return 0;
+}
+
// Construct a device id using label or manufacturer (vendor and model) details.
std::string MakeDeviceUniqueIdForUdevDevice(struct udev_device* device) {
std::string uuid = device::UdevDeviceGetPropertyValue(device, kFsUUID);
return orientation;
}
+int CameraHandle::GetCameraRotation() {
+ camera_rotation_e rotation = CAMERA_ROTATION_NONE;
+#if BUILDFLAG(IS_TIZEN_TV)
+#if TIZEN_VERSION_AT_LEAST(7, 0, 0)
+ int err = CAMERA_ERROR_NONE;
+ if (CAMERA_ERROR_NONE != (err = camera_attr_get_preview_frame_rotation(
+ camera_handle_, &rotation))) {
+ LOG(ERROR) << "Cannot get camera rotaion, Error:" << GetErrorString(err);
+ return 0;
+ }
+#endif
+#endif
+
+ return CameraRotaionToInt(rotation);
+}
+
#if BUILDFLAG(IS_TIZEN_TV)
void CameraHandle::CheckCurrentHandleChange(
VideoCaptureDeviceDescriptors* device_descriptors) {
return "UNKNOWN";
}
+media::VideoRotation ToVideoRotaion(int rotation) {
+ switch (rotation) {
+ case 0:
+ return media::VIDEO_ROTATION_0;
+ case 90:
+ return media::VIDEO_ROTATION_90;
+ case 180:
+ return media::VIDEO_ROTATION_180;
+ case 270:
+ return media::VIDEO_ROTATION_270;
+ }
+ NOTREACHED();
+ return media::VIDEO_ROTATION_0;
+}
+
} // unnamed namespace
namespace media {
if (self->first_ref_time_.is_null())
self->first_ref_time_ = now;
+ media::VideoFrameMetadata metadata;
+ const auto rotation = self->GetCurrentRotation();
+ metadata.transformation = media::VideoTransformation(rotation);
+
self->client_->OnIncomingCapturedBufferExt(
std::move(self->buffer_), videocaptureformat, gfx::ColorSpace(), now,
now - self->first_ref_time_, gfx::Rect(videocaptureformat.frame_size),
<< "total:" << self->frame_total_
<< " frame_timestamp:" << frame->timestamp << " width:" << frame->width
<< " height:" << frame->height
+ << " rotation:" << media::VideoRotationToString(rotation)
<< " format: " << CameraPixelFormatToString(frame->format)
<< " size: " << frame_size.ToString();
}
}
VideoRotation VideoCaptureDeviceTizen::GetCurrentRotation() const noexcept {
- NOTIMPLEMENTED();
+// NOTIMPLEMENTED();
+#if BUILDFLAG(IS_TIZEN_TV)
+ if (camera_instance_) {
+ // Three purposes to add rotation into captured frame:
+ // 1. Tv web engine need to keep captured subjects head up. Set camera
+ // rotation into video frame meta data will help to render video layer
+ // in corret orientation.
+ // 2. This rotation value will sent to peer side to trigger the video
+ // rotate in peer device
+ // 3. This rotation will trigger the natrual size changing in
+ // WebMediaPlayerMS then trigger resize event to video element
+ int camera_rotation = camera_instance_->GetCameraRotation();
+ int counterclockwise_camera_rotation = (360 - camera_rotation) % 360;
+ return ToVideoRotaion(counterclockwise_camera_rotation);
+ }
+#endif
return media::VIDEO_ROTATION_0;
}