Skip to content

Commit 0ac3af0

Browse files
authored
Amlogic - 2 (#1977)
* Correct AMVIDEOCAP_WAIT_MAX time * Use defalult FPS List from BaseClass * Limit to 30fps
1 parent 6b8b679 commit 0ac3af0

File tree

12 files changed

+29
-28
lines changed

12 files changed

+29
-28
lines changed

include/hyperion/Grabber.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ Q_DECLARE_LOGGING_CATEGORY(grabber_audio_benchmark);
4343
class Grabber : public QObject
4444
{
4545
Q_OBJECT
46+
public:
47+
static const QJsonArray DEFAULT_SUPPORTED_FPS_LIST;
4648

4749
public:
4850
explicit Grabber(const QString &grabberName = "", int cropLeft = 0, int cropRight = 0, int cropTop = 0, int cropBottom = 0);
@@ -150,6 +152,9 @@ class Grabber : public QObject
150152
virtual QSize getScreenSize() const { return QSize(); }
151153
virtual QJsonArray getInputDeviceDetails() const { return QJsonArray(); }
152154

155+
QJsonArray getFpsSupported() const { return _fpsSupportedList; }
156+
void setFpsSupported(const QJsonArray& fpsSupported) { _fpsSupportedList = fpsSupported; }
157+
153158
public slots:
154159

155160
virtual void handleEvent(Event event) { /* to be overridden by subclasses */ }
@@ -198,6 +203,9 @@ protected slots:
198203
/// fps software decimation
199204
int _fpsSoftwareDecimation;
200205

206+
// Supported fps values
207+
QJsonArray _fpsSupportedList;
208+
201209
/// device input
202210
int _input;
203211

libsrc/grabber/amlogic/AmlogicGrabber.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@ namespace
3232
const int DEFAULT_DEVICE_IDX = 0;
3333
const char DEFAULT_VIDEO_DEVICE[] = "/dev/amvideo";
3434
const char DEFAULT_CAPTURE_DEVICE[] = "/dev/amvideocap0";
35-
const int AMVIDEOCAP_WAIT_MAX_MS = 15;
36-
const int AMVIDEOCAP_DEFAULT_RATE_HZ = 25;
35+
// The Amlogic capture rate is driven by the video FPS. If video FPS is greater than 30hz, then it will be video FPS/2
36+
// The Hyperion rate is the frequence of frame grabs we attempt to do (but it is different from video FPS, as that is dynamic).
37+
const int AMVIDEOCAP_DEFAULT_RATE_HZ = 25;
38+
const int AMVIDEOCAP_WAIT_MAX_MS = 100; // Max wait time for frame capture. A capture time-out or pause scenario are identified, if rate falls under 10 fps (100ms per frame).
3739

3840
const size_t AMVIDEO_ALIGNMENT = 32; // Standard for Amlogic S905/S912
3941
} // End of constants
@@ -317,6 +319,9 @@ QJsonObject AmlogicGrabber::discover(const QJsonObject& /*params*/) const
317319
screenGrabber.reset(new FramebufferFrameGrabber(DEFAULT_DEVICE_IDX));
318320
}
319321

322+
//Overwrite default supported fps values
323+
screenGrabber->setFpsSupported({ 1, 5, 10, 15, 20, 25, 30 });
324+
320325
QJsonArray const video_inputs = screenGrabber->getInputDeviceDetails();
321326
if (video_inputs.isEmpty())
322327
{

libsrc/grabber/dda/DDAGrabber.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,7 @@ QJsonObject DDAGrabber::discover(const QJsonObject& params)
664664
{
665665
HRESULT hr = S_OK;
666666

667+
setFpsSupported(QJsonArray{1, 5, 10, 15, 20, 25, 30, 40, 50, 60, 120, 144});
667668
// Enumerate through the outputs.
668669
QJsonArray videoInputs;
669670
for (int i = 0;; ++i)
@@ -702,7 +703,7 @@ QJsonObject DDAGrabber::discover(const QJsonObject& params)
702703
QJsonObject{
703704
{"width", width},
704705
{"height", height},
705-
{"fps", QJsonArray{1, 5, 10, 15, 20, 25, 30, 40, 50, 60, 120, 144}},
706+
{"fps", getFpsSupported()},
706707
},
707708
}},
708709
},

libsrc/grabber/directx/DirectXGrabber.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,6 @@ QJsonObject DirectXGrabber::discover(const QJsonObject& params)
231231
inputsDiscovered["type"] = "screen";
232232

233233
QJsonArray video_inputs;
234-
QJsonArray fps = { 1, 5, 10, 15, 20, 25, 30, 40, 50, 60 };
235234

236235
for(int adapter = 0; adapter < adapterCount; adapter++)
237236
{
@@ -256,7 +255,7 @@ QJsonObject DirectXGrabber::discover(const QJsonObject& params)
256255

257256
resolution["width"] = (int)ddm.Width;
258257
resolution["height"] = (int)ddm.Height;
259-
resolution["fps"] = fps;
258+
resolution["fps"] = getFpsSupported();
260259

261260
resolutionArray.append(resolution);
262261
format["resolutions"] = resolutionArray;

libsrc/grabber/dispmanx/DispmanxFrameGrabber.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,6 @@ QJsonObject DispmanxFrameGrabber::discover(const QJsonObject& /*params*/)
312312
QSize screenSize = getScreenSize(deviceIdx);
313313
if ( !screenSize.isEmpty() )
314314
{
315-
QJsonArray fps = { 1, 5, 10, 15, 20, 25, 30, 40, 50, 60 };
316-
317315
QJsonObject in;
318316

319317
QString displayName;
@@ -331,7 +329,7 @@ QJsonObject DispmanxFrameGrabber::discover(const QJsonObject& /*params*/)
331329

332330
resolution["width"] = screenSize.width();
333331
resolution["height"] = screenSize.height();
334-
resolution["fps"] = fps;
332+
resolution["fps"] = getFpsSupported();
335333

336334
resolutionArray.append(resolution);
337335

libsrc/grabber/drm/DRMFrameGrabber.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,8 +1008,6 @@ QJsonArray DRMFrameGrabber::getInputDeviceDetails() const
10081008
//Only add devices with a valid screen size, i.e. where a monitor is connected
10091009
if ( !screenSize.isEmpty() )
10101010
{
1011-
QJsonArray fps = {"1", "5", "10", "15", "20", "25", "30", "40", "50", "60"};
1012-
10131011
QJsonObject input;
10141012

10151013
QString displayName;
@@ -1027,7 +1025,7 @@ QJsonArray DRMFrameGrabber::getInputDeviceDetails() const
10271025

10281026
resolution["width"] = screenSize.width();
10291027
resolution["height"] = screenSize.height();
1030-
resolution["fps"] = fps;
1028+
resolution["fps"] = getFpsSupported();
10311029

10321030
resolutionArray.append(resolution);
10331031

libsrc/grabber/framebuffer/FramebufferFrameGrabber.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,6 @@ QJsonArray FramebufferFrameGrabber::getInputDeviceDetails() const
203203
QSize screenSize = getScreenSize(device);
204204
if ( !screenSize.isEmpty() )
205205
{
206-
QJsonArray fps = { "1", "5", "10", "15", "20", "25", "30", "40", "50", "60" };
207-
208206
QJsonObject in;
209207

210208
QString displayName;
@@ -222,7 +220,7 @@ QJsonArray FramebufferFrameGrabber::getInputDeviceDetails() const
222220

223221
resolution["width"] = screenSize.width();
224222
resolution["height"] = screenSize.height();
225-
resolution["fps"] = fps;
223+
resolution["fps"] = getFpsSupported();
226224

227225
resolutionArray.append(resolution);
228226

libsrc/grabber/osx/OsxFrameGrabber.mm

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,6 @@ static CGImageRef capture15(CGDirectDisplayID id, CGRect diIntersectDisplayLocal
242242
inputsDiscovered["type"] = "screen";
243243

244244
QJsonArray video_inputs;
245-
QJsonArray fps = { 1, 5, 10, 15, 20, 25, 30, 40, 50, 60 };
246-
247245
for (int i = 0; i < static_cast<int>(dspyCnt); ++i)
248246
{
249247
QJsonObject in;
@@ -270,7 +268,7 @@ static CGImageRef capture15(CGDirectDisplayID id, CGRect diIntersectDisplayLocal
270268
resolution["height"] = static_cast<int>(rect.size.height);
271269
CGDisplayModeRelease(dispMode);
272270

273-
resolution["fps"] = fps;
271+
resolution["fps"] = getFpsSupported();
274272

275273
resolutionArray.append(resolution);
276274

libsrc/grabber/qt/QtGrabber.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -450,8 +450,6 @@ QJsonObject QtGrabber::discover(const QJsonObject& params)
450450
inputsDiscovered["type"] = "screen";
451451

452452
QJsonArray video_inputs;
453-
QJsonArray fps = { 1, 5, 10, 15, 20, 25, 30, 40, 50, 60 };
454-
455453
for (int i = 0; i < screens.size(); ++i)
456454
{
457455
QJsonObject in;
@@ -475,7 +473,7 @@ QJsonObject QtGrabber::discover(const QJsonObject& params)
475473

476474
resolution["width"] = screens.at(i)->size().width();
477475
resolution["height"] = screens.at(i)->size().height();
478-
resolution["fps"] = fps;
476+
resolution["fps"] = getFpsSupported();
479477

480478
resolutionArray.append(resolution);
481479

@@ -502,7 +500,7 @@ QJsonObject QtGrabber::discover(const QJsonObject& params)
502500

503501
resolution["width"] = screens.at(0)->virtualSize().width();
504502
resolution["height"] = screens.at(0)->virtualSize().height();
505-
resolution["fps"] = fps;
503+
resolution["fps"] = getFpsSupported();
506504

507505
resolutionArray.append(resolution);
508506

libsrc/grabber/x11/X11Grabber.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -417,8 +417,6 @@ QJsonObject X11Grabber::discover(const QJsonObject& params)
417417

418418
if (_x11Display != nullptr)
419419
{
420-
QJsonArray fps = { 1, 5, 10, 15, 20, 25, 30, 40, 50, 60 };
421-
422420
// Iterate through all X screens
423421
for (int i = 0; i < XScreenCount(_x11Display); ++i)
424422
{
@@ -453,7 +451,7 @@ QJsonObject X11Grabber::discover(const QJsonObject& params)
453451

454452
resolution["width"] = _windowAttr.width;
455453
resolution["height"] = _windowAttr.height;
456-
resolution["fps"] = fps;
454+
resolution["fps"] = getFpsSupported();
457455

458456
resolutionArray.append(resolution);
459457

0 commit comments

Comments
 (0)