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 <map>
6 #include <string>
7
8 #include <stdint.h>
9
10 #include <camera/camera_plugin.h>
11 #include <plugins/plugin_tools.h>
12
13 #include "mutex.h"
14
15 class DirContentsManager;
16
18 class StreamReader
19 :
20 public nxcip::StreamReader
21 {
22 public:
26 StreamReader(
27 nxpt::CommonRefManager* const parentRefManager,
28 DirContentsManager* const dirContentsManager,
29 unsigned int frameDurationUsec,
30 bool liveMode,
31 int encoderNumber );
32 virtual ~StreamReader();
33
35 virtual void* queryInterface( const nxpl::NX_GUID& interfaceID ) override;
37 virtual int addRef() const override;
39 virtual int releaseRef() const override;
40
42 virtual int getNextData( nxcip::MediaDataPacket** packet ) override;
44 virtual void interrupt() override;
45
46 nxcip::UsecUTCTimestamp setPosition(
47 unsigned int cSeq,
48 nxcip::UsecUTCTimestamp timestamp );
52 nxcip::UsecUTCTimestamp setReverseMode(
53 unsigned int cSeq,
54 bool isReverse,
55 nxcip::UsecUTCTimestamp timestamp );
56 bool isReverse() const;
57
58 private:
59 nxpt::CommonRefManager m_refManager;
60 DirContentsManager* const m_dirContentsManager;
61 nxcip::UsecUTCTimestamp m_curTimestamp;
62 const unsigned int m_frameDuration;
63 bool m_liveMode;
64 int m_encoderNumber;
65 std::map<nxcip::UsecUTCTimestamp, std::string> m_dirEntries;
66 std::map<nxcip::UsecUTCTimestamp, std::string>::const_iterator m_curPos;
67 bool m_streamReset;
68 nxcip::UsecUTCTimestamp m_nextFrameDeployTime;
69 mutable Mutex m_mutex;
70 bool m_isReverse;
71 unsigned int m_cSeq;
72
73 void doLiveDelay();
74 void readDirContents();
75 void moveCursorToNextFrame();
76 };
DirContentsManager
Manages information about image directory contents: Provides file list, generates timestamps of files...
Definition: dir_contents_manager.h:13
Mutex
Non-recursive non-named mutex.
Definition: mutex.h:11
nxcip::StreamReader
Used for reading media stream from camera.
Definition: camera_plugin.h:1168
StreamReader::queryInterface
virtual void * queryInterface(const nxpl::NX_GUID &interfaceID) override
Implementation of nxpl::PluginInterface::queryInterface.
Definition: stream_reader.cpp:64
StreamReader::getNextData
virtual int getNextData(nxcip::MediaDataPacket **packet) override
Implementation nxcip::StreamReader::getNextData.
Definition: stream_reader.cpp:91
nxpl::NX_GUID
GUID of plugin interface.
Definition: plugin_api.h:26
StreamReader::setReverseMode
nxcip::UsecUTCTimestamp setReverseMode(unsigned int cSeq, bool isReverse, nxcip::UsecUTCTimestamp timestamp)
Definition: stream_reader.cpp:230
StreamReader::StreamReader
StreamReader(nxpt::CommonRefManager *const parentRefManager, DirContentsManager *const dirContentsManager, unsigned int frameDurationUsec, bool liveMode, int encoderNumber)
Definition: stream_reader.cpp:35
nxpt::CommonRefManager
Definition: plugin_tools.h:67
plugin_tools.h
StreamReader::interrupt
virtual void interrupt() override
Implementation nxcip::StreamReader::interrupt.
Definition: stream_reader.cpp:193
StreamReader::addRef
virtual int addRef() const override
Implementation of nxpl::PluginInterface::addRef.
Definition: stream_reader.cpp:80
nxcip::MediaDataPacket
Portion of media data.
Definition: camera_plugin.h:1037
StreamReader::releaseRef
virtual int releaseRef() const override
Implementation of nxpl::PluginInterface::releaseRef.
Definition: stream_reader.cpp:86
StreamReader
Reads picture files from specified directory as video-stream.
Definition: stream_reader.h:18