Skip to content

Commit

Permalink
Merge pull request rdkcentral#5950 from viveksinghnarwaria/screen_cap…
Browse files Browse the repository at this point in the history
…ture_main

Merge pull request rdkcentral#5879 from maruku/sprint/24Q4
  • Loading branch information
anand-ky authored Dec 19, 2024
2 parents a79f4a6 + 43530bc commit 603cf74
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 15 deletions.
4 changes: 4 additions & 0 deletions ScreenCapture/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ All notable changes to this RDK Service will be documented in this file.
* For more details, refer to [versioning](https://github.com/rdkcentral/rdkservices#versioning) section under Main README.


## [1.0.7] - 2024-12-18
### Fixed
- Fix Realtek DRM screencapture implementation

## [1.0.6] - 2024-07-30
### Added
- Fixed nxclient library issue for braodcom devices and screen shot setting
Expand Down
29 changes: 15 additions & 14 deletions ScreenCapture/Implementation/Realtek/Realtek.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <sys/ioctl.h>
#include "kms.h"
#include "Realtek.h"

Expand Down Expand Up @@ -81,7 +82,6 @@ bool DRMScreenCapture_GetScreenInfo(DRMScreenCapture* handle) {
// open drm device to get screen information
int retryCount = 0;
drmModePlane *plane = nullptr;
struct drm_mode_map_dumb map = {};

context->fd = open(DEFAULT_DEVICE, O_RDWR);
if(!context->fd) {
Expand Down Expand Up @@ -147,15 +147,19 @@ bool DRMScreenCapture_GetScreenInfo(DRMScreenCapture* handle) {
ret = false;
break;
}
map.handle = fb->handle;
int drmRet = drmIoctl(context->fd, DRM_IOCTL_MODE_MAP_DUMB, &map);

struct drm_prime_handle drm_prime;
int drmRet = 0;

drm_prime.handle = fb->handle;
drm_prime.flags = 0;
drmRet = ioctl(context->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &drm_prime);
if(drmRet) {
cout << "[SCREENCAP] drmIoctl fail, ret=" << drmRet << endl;
cout << "[SCREENCAP] drmIoctl(DRM_IOCTL_PRIME_HANDLE_TO_FD) fail, ret=" << drmRet << endl;
ret = false;
break;
}
context->offset = map.offset;
cout << "[SCREENCAP] offset : " << map.offset << endl;
handle->dmabuf_fd = drm_prime.fd;
} while(false);

if(fb)
Expand All @@ -166,17 +170,15 @@ bool DRMScreenCapture_GetScreenInfo(DRMScreenCapture* handle) {
}

bool DRMScreenCapture_ScreenCapture(DRMScreenCapture* handle, uint8_t* output, uint32_t bufSize) {
DRMContext *context;
bool ret = true;

do {
if(!handle || !handle->context || !output) {
if(!handle || !output) {
cout << "[SCREENCAP] null input parameter" << endl;
ret = false;
break;
}

context = (DRMContext*) handle->context;
uint32_t size = handle->pitch * handle->height;
if(bufSize < size) {
// buffer size not match
Expand All @@ -186,12 +188,11 @@ bool DRMScreenCapture_ScreenCapture(DRMScreenCapture* handle, uint8_t* output, u

// copy frame
void *vaddr = NULL;
vaddr =(void*) mmap(NULL, size, PROT_READ , MAP_SHARED, context->fd, context->offset) ;

vaddr =(void*) mmap64(NULL, size, PROT_READ , MAP_SHARED, handle->dmabuf_fd, 0);
if (vaddr == MAP_FAILED) {
perror("mmap failed : ");
ret = false;
break;
cout << "[SCREENCAP] mmap failed" << endl;
ret = false;
break;
}

memcpy(output,(unsigned char*)vaddr, size);
Expand Down
1 change: 1 addition & 0 deletions ScreenCapture/Implementation/Realtek/Realtek.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ typedef struct DRMScreenCapture_s {
uint32_t height;
uint32_t pitch;
uint8_t bpp;
int dmabuf_fd;
}DRMScreenCapture;

DRMScreenCapture* DRMScreenCapture_Init();
Expand Down
2 changes: 1 addition & 1 deletion ScreenCapture/ScreenCapture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

#define API_VERSION_NUMBER_MAJOR 1
#define API_VERSION_NUMBER_MINOR 0
#define API_VERSION_NUMBER_PATCH 6
#define API_VERSION_NUMBER_PATCH 7

namespace WPEFramework
{
Expand Down

0 comments on commit 603cf74

Please sign in to comment.