nx_server_plugin_sdk 1.0 Server Plugin SDK

stream_reader.h
1 // Copyright 2018-present Network Optix, Inc. Licensed under MPL 2.0: www.mozilla.org/MPL/2.0/
2
3 #pragma once
4
5 #include <string>
6
7 #include <camera/camera_plugin.h>
8 #include <nx/sdk/cloud_storage/i_codec_info.h>
9 #include <nx/sdk/cloud_storage/i_stream_reader.h>
10 #include <nx/sdk/helpers/list.h>
11 #include <nx/sdk/helpers/ref_countable.h>
12 #include <nx/sdk/result.h>
13 #include <plugins/plugin_tools.h>
14
15 #include "data_manager.h"
16
17 namespace nx::vms_server_plugins::cloud_storage::stub {
18
19 class StreamReader: public nx::sdk::RefCountable<nx::sdk::cloud_storage::IStreamReader>
20 {
21 public:
22 StreamReader(
23 const std::shared_ptr<DataManager>& dataManager,
24 const std::string& bucketUrl,
25 const std::string& deviceId,
26 int streamIndex,
27 int64_t startTimeMs,
28 int64_t durationMs);
29
30 virtual nx::sdk::ErrorCode getNextData(nx::sdk::cloud_storage::IMediaDataPacket** packet) override;
31 virtual int64_t startTimeUs() const override;
32 virtual int64_t endTimeUs() const override;
33 virtual nx::sdk::ErrorCode seek(
34 int64_t timestampUs, bool findKeyFrame, int64_t* selectedPositionUs) override;
35 virtual int size() const override;
36
37 protected:
38 virtual void getOpaqueMetadata(
39 nx::sdk::Result<const nx::sdk::IString*>* outResult) const override;
40 virtual const nx::sdk::IList<nx::sdk::cloud_storage::ICodecInfo>* getCodecInfoList() const override;
41
42 private:
43 std::shared_ptr<DataManager> m_dataManager;
44 std::string m_deviceId;
45 int m_streamIndex = -1;
46 const int64_t m_timestampUs;
47 const int64_t m_durationUs;
48 nx::sdk::Ptr<nx::sdk::List<nx::sdk::cloud_storage::ICodecInfo>> m_codecInfos;
49 std::unique_ptr<ReadableMediaFile> m_file;
50 std::string m_opaqueMetadata;
51 int m_packetCount = 0;
52
53 };
54
55 } // namespace nx::vms_server_plugins::cloud_storage::stub
nx::vms_server_plugins::cloud_storage::stub::StreamReader::size
virtual int size() const override
Definition: stream_reader.cpp:51
nx::sdk::cloud_storage::IMediaDataPacket
Definition: i_media_data_packet.h:17
nx::vms_server_plugins::cloud_storage::stub
Definition: data_manager.cpp:36
nx::vms_server_plugins::cloud_storage::stub::StreamReader::getNextData
virtual nx::sdk::ErrorCode getNextData(nx::sdk::cloud_storage::IMediaDataPacket **packet) override
Definition: stream_reader.cpp:56
nx::vms_server_plugins::cloud_storage::stub::StreamReader::seek
virtual nx::sdk::ErrorCode seek(int64_t timestampUs, bool findKeyFrame, int64_t *selectedPositionUs) override
Definition: stream_reader.cpp:77
nx::sdk::Ptr
Definition: ptr.h:18
nx::sdk::Result
Definition: result.h:52
nx::vms_server_plugins::cloud_storage::stub::StreamReader
Definition: stream_reader.h:19
plugin_tools.h
nx::sdk::IList< nx::sdk::cloud_storage::ICodecInfo >
nx::sdk::RefCountable
Definition: ref_countable.h:83