Update the methods in BaseUseCase.h
* Remove the streamFrame method
* Rename startVideoStreaming to startVideoStream, as well as
stopVideoStreaming to stopVideoStream, to match the signature in
IEvsCamera
* Add comments for all the methods
Test: build and run on Hawk device
Bug: 130246434
Change-Id: Idf9242207c339142d91c7f7a714eca8fc852972c
diff --git a/evs/apps/demo_app_evs_support_lib/evs_app_support_lib.cpp b/evs/apps/demo_app_evs_support_lib/evs_app_support_lib.cpp
index 2c1e351..c0760f6 100644
--- a/evs/apps/demo_app_evs_support_lib/evs_app_support_lib.cpp
+++ b/evs/apps/demo_app_evs_support_lib/evs_app_support_lib.cpp
@@ -69,9 +69,9 @@
DisplayUseCase::createDefaultUseCase(cameraId, new SimpleRenderCallback());
// Stream the video for 5 seconds.
- if (useCase.startVideoStreaming()) {
+ if (useCase.startVideoStream()) {
std::this_thread::sleep_for(std::chrono::seconds(5));
- useCase.stopVideoStreaming();
+ useCase.stopVideoStream();
}
return 0;
diff --git a/evs/support_library/BaseUseCase.h b/evs/support_library/BaseUseCase.h
index 012fd53..bae0721 100644
--- a/evs/support_library/BaseUseCase.h
+++ b/evs/support_library/BaseUseCase.h
@@ -21,13 +21,41 @@
namespace evs {
namespace support {
+/**
+ * Base class for all the use cases in the EVS support library.
+ */
class BaseUseCase {
- public:
- virtual bool startVideoStreaming() = 0;
- virtual void stopVideoStreaming() = 0;
- virtual bool streamFrame() = 0;
- virtual ~BaseUseCase() {
- }
+public:
+ /**
+ * Requests delivery of camera frames from the desired EVS camera(s). The
+ * use case begins receiving periodic calls from EVS camera with new image
+ * frames until stopVideoStream is called.
+ *
+ * If the same EVS camera has already been started by other use cases,
+ * the frame delivery to this use case starts without affecting the status
+ * of the EVS camera.
+ *
+ * @return Returns true if the video stream is started successfully.
+ * Otherwise returns false.
+ *
+ * @see stopVideoStream()
+ */
+ virtual bool startVideoStream() = 0;
+
+ /**
+ * Stops the delivery of EVS camera frames, and tries to close the EVS
+ * camera. Because delivery is asynchronous, frames may continue to
+ * arrive for some time after this call returns.
+ *
+ * If other use cases are using the camera at the same time, the EVS
+ * camera will not be closed, until all the other use cases using the
+ * camera are stopped.
+ *
+ * @see startVideoStream()
+ */
+ virtual void stopVideoStream() = 0;
+
+ virtual ~BaseUseCase() {}
};
} // namespace support
diff --git a/evs/support_library/DisplayUseCase.cpp b/evs/support_library/DisplayUseCase.cpp
index 86e6e73..7782030 100644
--- a/evs/support_library/DisplayUseCase.cpp
+++ b/evs/support_library/DisplayUseCase.cpp
@@ -95,7 +95,7 @@
return false;
}
-bool DisplayUseCase::startVideoStreaming() {
+bool DisplayUseCase::startVideoStream() {
// Initialize the use case.
if (!mIsInitialized && !initialize()) {
ALOGE("There is an error while initializing the use case. Exiting");
@@ -142,7 +142,7 @@
return true;
}
-void DisplayUseCase::stopVideoStreaming() {
+void DisplayUseCase::stopVideoStream() {
ALOGD("Stop video streaming in worker thread.");
mIsReadyToRun = false;
return;
diff --git a/evs/support_library/DisplayUseCase.h b/evs/support_library/DisplayUseCase.h
index 19c22c2..4d6f12b 100644
--- a/evs/support_library/DisplayUseCase.h
+++ b/evs/support_library/DisplayUseCase.h
@@ -43,8 +43,8 @@
class DisplayUseCase : public BaseUseCase {
public:
~DisplayUseCase();
- bool startVideoStreaming() override;
- void stopVideoStreaming() override;
+ bool startVideoStream() override;
+ void stopVideoStream() override;
// TODO(b/130246434): Add configuration class to create more use case.
static DisplayUseCase createDefaultUseCase(string cameraId,