StreamDecoderImageProvider.h
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * ArmarX is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation.
7  *
8  * ArmarX is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * @package VisionX::ArmarXObjects::StreamDecoderImageProvider
17  * @author Mirko Waechter ( mirko dot waechter at kit dot edu )
18  * @date 2016
19  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20  * GNU General Public License
21  */
22 
23 #pragma once
24 
25 
27 
29 #include <VisionX/interface/components/StreamProvider.h>
30 
31 extern "C"
32 {
33 #include <libavcodec/avcodec.h>
34 #include <libswscale/swscale.h>
35 }
36 
37 #include <mutex>
38 
39 class CByteImage;
40 
41 namespace armarx
42 {
43  /**
44  * @class StreamDecoderImageProviderPropertyDefinitions
45  * @brief
46  */
49  {
50  public:
53  {
54  defineOptionalProperty<std::string>("UsedStreamProvider",
55  "StreamProvider",
56  "Names of the StreamProvider that is to be used");
57  defineOptionalProperty<std::string>(
58  "imageStreamTopicName", "ImageStream", "Name of the image streaming topic");
59 
60  //defineRequiredProperty<std::string>("PropertyName", "Description");
61  //defineOptionalProperty<std::string>("PropertyName", "DefaultValue", "Description");
62  }
63  };
64 
65  /**
66  * @defgroup Component-StreamDecoderImageProvider StreamDecoderImageProvider
67  * @ingroup VisionX-Components
68  * A description of the component StreamDecoderImageProvider.
69  *
70  * @class StreamDecoderImageProvider
71  * @ingroup Component-StreamDecoderImageProvider
72  * @brief Brief description of class StreamDecoderImageProvider.
73  *
74  * Detailed description of class StreamDecoderImageProvider.
75  */
77  virtual public visionx::ImageProvider,
78  public Stream::StreamListenerInterface
79  {
80  public:
81  /**
82  * @see armarx::ManagedIceObject::getDefaultName()
83  */
84  std::string
85  getDefaultName() const override
86  {
87  return "StreamDecoderImageProvider";
88  }
89 
90  protected:
91  void onInitImageProvider() override;
92  void onConnectComponent() override;
93  void onDisconnectImageProvider() override;
94  void onExitImageProvider() override;
95 
96  /**
97  * @see PropertyUser::createPropertyDefinitions()
98  */
100  // StreamListenerInterface interface
101  Stream::StreamProviderPrx streamProvider;
102  void reportNewStreamData(const Stream::DataChunk& chunk,
103  Ice::Long imageTimestamp,
104  const Ice::Current&) override;
106  AVCodec* m_decoder;
107  AVCodecContext* m_decoderContext;
109  AVFrame* m_picture;
110  AVPacket m_packet;
111  std::mutex decodedImageMutex;
112  std::mutex streamDecodeMutex;
113  SwsContext* m_swsCtx = NULL;
115  };
116 } // namespace armarx
armarx::StreamDecoderImageProvider::numberImages
int numberImages
Definition: StreamDecoderImageProvider.h:105
armarx::StreamDecoderImageProvider::onDisconnectImageProvider
void onDisconnectImageProvider() override
Definition: StreamDecoderImageProvider.cpp:91
armarx::StreamDecoderImageProvider::m_swsCtx
SwsContext * m_swsCtx
Definition: StreamDecoderImageProvider.h:113
armarx::StreamDecoderImageProvider::m_packet
AVPacket m_packet
Definition: StreamDecoderImageProvider.h:110
armarx::StreamDecoderImageProvider::decodedImageMutex
std::mutex decodedImageMutex
Definition: StreamDecoderImageProvider.h:111
armarx::StreamDecoderImageProvider::onExitImageProvider
void onExitImageProvider() override
This is called when the Component::onExitComponent() setup is called.
Definition: StreamDecoderImageProvider.cpp:109
armarx::StreamDecoderImageProviderPropertyDefinitions::StreamDecoderImageProviderPropertyDefinitions
StreamDecoderImageProviderPropertyDefinitions(std::string prefix)
Definition: StreamDecoderImageProvider.h:51
armarx::PropertyDefinitionContainer::prefix
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Definition: PropertyDefinitionContainer.h:345
armarx::StreamDecoderImageProvider::streamDecodeMutex
std::mutex streamDecodeMutex
Definition: StreamDecoderImageProvider.h:112
armarx::StreamDecoderImageProvider::pCombinedDecodedImage
CByteImage * pCombinedDecodedImage
Definition: StreamDecoderImageProvider.h:114
armarx::StreamDecoderImageProvider::m_picture
AVFrame * m_picture
Definition: StreamDecoderImageProvider.h:109
armarx::StreamDecoderImageProvider
Brief description of class StreamDecoderImageProvider.
Definition: StreamDecoderImageProvider.h:76
armarx::VariantType::Long
const VariantTypeId Long
Definition: Variant.h:918
armarx::StreamDecoderImageProvider::m_decoderContext
AVCodecContext * m_decoderContext
Definition: StreamDecoderImageProvider.h:107
Component.h
armarx::StreamDecoderImageProvider::m_decoder
AVCodec * m_decoder
Definition: StreamDecoderImageProvider.h:106
visionx::ImageProvider
ImageProvider abstract class defines a component which provide images via ice or shared memory.
Definition: ImageProvider.h:66
armarx::StreamDecoderImageProvider::ppDecodedImages
CByteImage ** ppDecodedImages
Definition: StreamDecoderImageProvider.h:114
armarx::ComponentPropertyDefinitions
Default component property definition container.
Definition: Component.h:69
armarx::StreamDecoderImageProvider::createPropertyDefinitions
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: StreamDecoderImageProvider.cpp:114
armarx::StreamDecoderImageProvider::onInitImageProvider
void onInitImageProvider() override
This is called when the Component::onInitComponent() is called.
Definition: StreamDecoderImageProvider.cpp:29
armarx::StreamDecoderImageProvider::reportNewStreamData
void reportNewStreamData(const Stream::DataChunk &chunk, Ice::Long imageTimestamp, const Ice::Current &) override
Definition: StreamDecoderImageProvider.cpp:121
IceUtil::Handle< class PropertyDefinitionContainer >
armarx::StreamDecoderImageProvider::getDefaultName
std::string getDefaultName() const override
Definition: StreamDecoderImageProvider.h:85
armarx::StreamDecoderImageProvider::streamProvider
Stream::StreamProviderPrx streamProvider
Definition: StreamDecoderImageProvider.h:101
armarx::StreamDecoderImageProviderPropertyDefinitions
Definition: StreamDecoderImageProvider.h:47
armarx::StreamDecoderImageProvider::onConnectComponent
void onConnectComponent() override
Pure virtual hook for the subclass.
Definition: StreamDecoderImageProvider.cpp:68
ImageProvider.h
armarx::StreamDecoderImageProvider::m_got_picture
int m_got_picture
Definition: StreamDecoderImageProvider.h:108
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27