00001 #include <message_transport/simple_subscriber_plugin.h> 00002 #include <theora_imagem_transport/packet.h> 00003 #include <cv_bridge/CvBridge.h> 00004 00005 #include <theora/codec.h> 00006 #include <theora/theoraenc.h> 00007 #include <theora/theoradec.h> 00008 00009 namespace theora_imagem_transport { 00010 00011 class TheoraSubscriber : public message_transport::SimpleSubscriberPlugin<sensor_msgs::Image,theora_imagem_transport::packet> 00012 { 00013 public: 00014 TheoraSubscriber(); 00015 virtual ~TheoraSubscriber(); 00016 00017 virtual std::string getTransportName() const 00018 { 00019 return "theora"; 00020 } 00021 00022 protected: 00023 //The function that does the actual decompression and calls a user supplied callback with the resulting image 00024 virtual void internalCallback(const theora_imagem_transport::packet::ConstPtr &msg, 00025 const message_transport::SimpleSubscriberPlugin<sensor_msgs::Image,theora_imagem_transport::packet>::Callback& user_cb); 00026 00027 private: 00028 void msgToOggPacket(const theora_imagem_transport::packet &msg, ogg_packet &oggpacketOutput); 00029 00030 bool received_header_; 00031 th_dec_ctx* decoding_context_; 00032 th_info header_info_; 00033 th_comment header_comment_; 00034 th_setup_info* setup_info_; 00035 sensor_msgs::CvBridge img_bridge_; 00036 }; 00037 00038 } //namespace theora_imagem_transport