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 
28 #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", "StreamProvider", "Names of the StreamProvider that is to be used");
55  defineOptionalProperty<std::string>("imageStreamTopicName", "ImageStream", "Name of the image streaming topic");
56 
57  //defineRequiredProperty<std::string>("PropertyName", "Description");
58  //defineOptionalProperty<std::string>("PropertyName", "DefaultValue", "Description");
59  }
60  };
61 
62  /**
63  * @defgroup Component-StreamDecoderImageProvider StreamDecoderImageProvider
64  * @ingroup VisionX-Components
65  * A description of the component StreamDecoderImageProvider.
66  *
67  * @class StreamDecoderImageProvider
68  * @ingroup Component-StreamDecoderImageProvider
69  * @brief Brief description of class StreamDecoderImageProvider.
70  *
71  * Detailed description of class StreamDecoderImageProvider.
72  */
74  virtual public visionx::ImageProvider,
75  public Stream::StreamListenerInterface
76  {
77  public:
78  /**
79  * @see armarx::ManagedIceObject::getDefaultName()
80  */
81  std::string getDefaultName() const override
82  {
83  return "StreamDecoderImageProvider";
84  }
85 
86  protected:
87  void onInitImageProvider() override;
88  void onConnectComponent() override;
89  void onDisconnectImageProvider() override;
90  void onExitImageProvider() override;
91 
92  /**
93  * @see PropertyUser::createPropertyDefinitions()
94  */
96  // StreamListenerInterface interface
97  Stream::StreamProviderPrx streamProvider;
98  void reportNewStreamData(const Stream::DataChunk& chunk, Ice::Long imageTimestamp, const Ice::Current&) override;
100  AVCodec* m_decoder;
101  AVCodecContext* m_decoderContext;
103  AVFrame* m_picture;
104  AVPacket m_packet;
105  std::mutex decodedImageMutex;
106  std::mutex streamDecodeMutex;
107  SwsContext* m_swsCtx = NULL;
109  };
110 }
111 
armarx::StreamDecoderImageProvider::numberImages
int numberImages
Definition: StreamDecoderImageProvider.h:99
armarx::StreamDecoderImageProvider::onDisconnectImageProvider
void onDisconnectImageProvider() override
Definition: StreamDecoderImageProvider.cpp:89
armarx::StreamDecoderImageProvider::m_swsCtx
SwsContext * m_swsCtx
Definition: StreamDecoderImageProvider.h:107
armarx::StreamDecoderImageProvider::m_packet
AVPacket m_packet
Definition: StreamDecoderImageProvider.h:104
armarx::StreamDecoderImageProvider::decodedImageMutex
std::mutex decodedImageMutex
Definition: StreamDecoderImageProvider.h:105
armarx::StreamDecoderImageProvider::onExitImageProvider
void onExitImageProvider() override
This is called when the Component::onExitComponent() setup is called.
Definition: StreamDecoderImageProvider.cpp:108
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:333
armarx::StreamDecoderImageProvider::streamDecodeMutex
std::mutex streamDecodeMutex
Definition: StreamDecoderImageProvider.h:106
armarx::StreamDecoderImageProvider::pCombinedDecodedImage
CByteImage * pCombinedDecodedImage
Definition: StreamDecoderImageProvider.h:108
armarx::StreamDecoderImageProvider::m_picture
AVFrame * m_picture
Definition: StreamDecoderImageProvider.h:103
armarx::StreamDecoderImageProvider
Brief description of class StreamDecoderImageProvider.
Definition: StreamDecoderImageProvider.h:73
armarx::VariantType::Long
const VariantTypeId Long
Definition: Variant.h:917
armarx::StreamDecoderImageProvider::m_decoderContext
AVCodecContext * m_decoderContext
Definition: StreamDecoderImageProvider.h:101
Component.h
armarx::StreamDecoderImageProvider::m_decoder
AVCodec * m_decoder
Definition: StreamDecoderImageProvider.h:100
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:108
armarx::ComponentPropertyDefinitions
Default component property definition container.
Definition: Component.h:70
armarx::StreamDecoderImageProvider::createPropertyDefinitions
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: StreamDecoderImageProvider.cpp:113
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:119
IceUtil::Handle< class PropertyDefinitionContainer >
armarx::StreamDecoderImageProvider::getDefaultName
std::string getDefaultName() const override
Definition: StreamDecoderImageProvider.h:81
armarx::StreamDecoderImageProvider::streamProvider
Stream::StreamProviderPrx streamProvider
Definition: StreamDecoderImageProvider.h:97
armarx::StreamDecoderImageProviderPropertyDefinitions
Definition: StreamDecoderImageProvider.h:47
armarx::StreamDecoderImageProvider::onConnectComponent
void onConnectComponent() override
Pure virtual hook for the subclass.
Definition: StreamDecoderImageProvider.cpp:67
ImageProvider.h
armarx::StreamDecoderImageProvider::m_got_picture
int m_got_picture
Definition: StreamDecoderImageProvider.h:102
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28