introduced frame catcher to channels, add framecatcher in Retroshare.pro to build it in

(only works for linux at the moment)

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3821 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
chrisparker126 2010-11-19 00:47:18 +00:00
parent b0aa255ead
commit a9ee3d92dc
6 changed files with 190 additions and 101 deletions

View File

@ -1,4 +1,4 @@
CONFIG += qt gui uic qrc resources uitools idle bitdht # blogs CONFIG += qt gui uic qrc resources uitools idle bitdht # framecatcher# blogs
QT += network xml script opengl QT += network xml script opengl
TEMPLATE = app TEMPLATE = app
@ -669,6 +669,20 @@ SOURCES += idle/idle.cpp \
idle/idle_platform.cpp idle/idle_platform.cpp
} }
framecatcher {
HEADERS += util/framecatcher.h
SOURCES += util/framecatcher.cpp
LIBS += -lxine
DEFINES *= CHANNELS_FRAME_CATCHER
}
minimal { minimal {
SOURCES = main.cpp \ SOURCES = main.cpp \
rshare.cpp \ rshare.cpp \

View File

@ -37,7 +37,7 @@
/** Constructor */ /** Constructor */
CreateChannelMsg::CreateChannelMsg(std::string cId) CreateChannelMsg::CreateChannelMsg(std::string cId)
: QDialog (NULL), mChannelId(cId) ,mCheckAttachment(true) : QDialog (NULL), mChannelId(cId) ,mCheckAttachment(true), mAutoMediaThumbNail(false)
{ {
/* Invoke the Qt Designer generated object setup routine */ /* Invoke the Qt Designer generated object setup routine */
setupUi(this); setupUi(this);
@ -50,7 +50,10 @@ CreateChannelMsg::CreateChannelMsg(std::string cId)
connect(addFileButton, SIGNAL(clicked() ), this , SLOT(addExtraFile())); connect(addFileButton, SIGNAL(clicked() ), this , SLOT(addExtraFile()));
connect(addfilepushButton, SIGNAL(clicked() ), this , SLOT(addExtraFile())); connect(addfilepushButton, SIGNAL(clicked() ), this , SLOT(addExtraFile()));
connect(addThumbnailButton, SIGNAL(clicked() ), this , SLOT(addThumbnail())); connect(addThumbnailButton, SIGNAL(clicked() ), this , SLOT(addThumbnail()));
connect(thumbNailCb, SIGNAL(toggled(bool)), this, SLOT(allowAutoMediaThumbNail(bool)));
#ifdef CHANNELS_FRAME_CATCHER
fCatcher = new framecatcher();
#endif
//buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); //buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
setAcceptDrops(true); setAcceptDrops(true);
@ -58,6 +61,14 @@ CreateChannelMsg::CreateChannelMsg(std::string cId)
newChannelMsg(); newChannelMsg();
} }
CreateChannelMsg::~CreateChannelMsg(){
#ifdef CHANNELS_FRAME_CATCHER
delete fCatcher;
#endif
}
/* Dropping */ /* Dropping */
void CreateChannelMsg::dragEnterEvent(QDragEnterEvent *event) void CreateChannelMsg::dragEnterEvent(QDragEnterEvent *event)
@ -299,6 +310,9 @@ void CreateChannelMsg::addAttachment(const std::string &path)
std::cerr << "CreateChannelMsg::addAttachment()"; std::cerr << "CreateChannelMsg::addAttachment()";
std::cerr << std::endl; std::cerr << std::endl;
if(mAutoMediaThumbNail)
setThumbNail(path, 2000);
/* add widget in for new destination */ /* add widget in for new destination */
uint32_t flags = SFI_TYPE_CHANNEL | SFI_STATE_EXTRA; uint32_t flags = SFI_TYPE_CHANNEL | SFI_STATE_EXTRA;
@ -343,6 +357,59 @@ void CreateChannelMsg::addAttachment(const std::string &path)
} }
bool CreateChannelMsg::setThumbNail(const std::string& path, int frame){
#ifdef CHANNELS_FRAME_CATCHER
unsigned char* imageBuffer = NULL;
int width = 0, height = 0, errCode = 0;
int length;
std::string errString;
if(1 != (errCode = fCatcher->open(path))){
fCatcher->getError(errCode, errString);
std::cerr << errString << std::endl;
return false;
}
length = fCatcher->getLength();
// make sure frame chosen is at lease a quarter length of video length if not choose quarter length
if(frame < (int) (0.25 * length))
frame = 0.25 * length;
if(1 != (errCode = fCatcher->getRGBImage(frame, imageBuffer, width, height))){
fCatcher->getError(errCode, errString);
std::cerr << errString << std::endl;
return false;
}
if(imageBuffer == NULL)
return false;
QImage tNail(imageBuffer, width, height, QImage::Format_RGB32);
QByteArray ba;
QBuffer buffer(&ba);
buffer.open(QIODevice::WriteOnly);
tNail.save(&buffer, "PNG");
QPixmap img;
img.loadFromData(ba, "PNG");
img = img.scaled(thumbnail_label->width(), thumbnail_label->height(), Qt::KeepAspectRatio);
thumbnail_label->setPixmap(img);
delete[] imageBuffer;
#endif
return true;
}
void CreateChannelMsg::allowAutoMediaThumbNail(bool allowThumbNail){
mAutoMediaThumbNail = allowThumbNail;
}
void CreateChannelMsg::checkAttachmentReady() void CreateChannelMsg::checkAttachmentReady()
{ {
std::list<SubFileItem *>::iterator fit; std::list<SubFileItem *>::iterator fit;

View File

@ -25,6 +25,10 @@
#include "ui_CreateChannelMsg.h" #include "ui_CreateChannelMsg.h"
#include <stdint.h> #include <stdint.h>
#ifdef CHANNELS_FRAME_CATCHER
#include "util/framecatcher.h"
#endif
class SubFileItem; class SubFileItem;
class FileInfo; class FileInfo;
@ -35,7 +39,10 @@ class CreateChannelMsg : public QDialog, private Ui::CreateChannelMsg
public: public:
/** Default Constructor */ /** Default Constructor */
CreateChannelMsg(std::string cId); CreateChannelMsg(std::string cId);
/** Default Destructor */ /** Default Destructor */
~CreateChannelMsg();
void addAttachment(const std::string &path); void addAttachment(const std::string &path);
void addAttachment(const std::string &hash, const std::string &fname, uint64_t size, bool local, const std::string &srcId); void addAttachment(const std::string &hash, const std::string &fname, uint64_t size, bool local, const std::string &srcId);
@ -56,18 +63,26 @@ private slots:
void sendMsg(); void sendMsg();
void addThumbnail(); void addThumbnail();
void allowAutoMediaThumbNail(bool);
private: private:
void parseRsFileListAttachments(const std::string &attachList); void parseRsFileListAttachments(const std::string &attachList);
void sendMessage(std::wstring subject, std::wstring msg, std::list<FileInfo> &files); void sendMessage(std::wstring subject, std::wstring msg, std::list<FileInfo> &files);
bool setThumbNail(const std::string& path, int frame);
std::string mChannelId; std::string mChannelId;
std::list<SubFileItem *> mAttachments; std::list<SubFileItem *> mAttachments;
bool mCheckAttachment; bool mCheckAttachment;
bool mAutoMediaThumbNail;
#ifdef CHANNELS_FRAME_CATCHER
framecatcher* fCatcher;
#endif
}; };
#endif #endif

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>509</width> <width>509</width>
<height>464</height> <height>479</height>
</rect> </rect>
</property> </property>
<property name="acceptDrops"> <property name="acceptDrops">
@ -97,7 +97,7 @@ p, li { white-space: pre-wrap; }
<item row="0" column="0"> <item row="0" column="0">
<widget class="QTabWidget" name="tabWidget"> <widget class="QTabWidget" name="tabWidget">
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>1</number>
</property> </property>
<widget class="QWidget" name="tab"> <widget class="QWidget" name="tab">
<attribute name="title"> <attribute name="title">
@ -248,25 +248,8 @@ p, li { white-space: pre-wrap; }
<attribute name="title"> <attribute name="title">
<string>Attachments</string> <string>Attachments</string>
</attribute> </attribute>
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QGridLayout" name="gridLayout_4">
<property name="spacing"> <item row="0" column="0">
<number>0</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>6</number>
</property>
<item>
<widget class="QLabel" name="label_3"> <widget class="QLabel" name="label_3">
<property name="text"> <property name="text">
<string/> <string/>
@ -276,7 +259,7 @@ p, li { white-space: pre-wrap; }
</property> </property>
</widget> </widget>
</item> </item>
<item> <item row="0" column="1">
<widget class="QLabel" name="label_4"> <widget class="QLabel" name="label_4">
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
@ -295,7 +278,7 @@ p, li { white-space: pre-wrap; }
</property> </property>
</widget> </widget>
</item> </item>
<item> <item row="0" column="2">
<spacer> <spacer>
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
@ -308,7 +291,7 @@ p, li { white-space: pre-wrap; }
</property> </property>
</spacer> </spacer>
</item> </item>
<item> <item row="0" column="3">
<widget class="QPushButton" name="addFileButton"> <widget class="QPushButton" name="addFileButton">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed"> <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
@ -337,9 +320,17 @@ p, li { white-space: pre-wrap; }
</property> </property>
</widget> </widget>
</item> </item>
</layout> <item row="0" column="4">
<widget class="QCheckBox" name="thumbNailCb">
<property name="toolTip">
<string> allow channels to get frame for message thumbnail from movie media attachments or not</string>
</property>
<property name="text">
<string>Auto Thumbnail</string>
</property>
</widget>
</item> </item>
<item> <item row="1" column="0" colspan="5">
<widget class="QScrollArea" name="scrollArea"> <widget class="QScrollArea" name="scrollArea">
<property name="verticalScrollBarPolicy"> <property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOn</enum> <enum>Qt::ScrollBarAlwaysOn</enum>
@ -352,8 +343,8 @@ p, li { white-space: pre-wrap; }
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>464</width> <width>456</width>
<height>282</height> <height>251</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">

View File

@ -306,7 +306,7 @@ unsigned char * framecatcher::yv12ToRgb (uint8_t *src_y, uint8_t *src_u, uint8_t
return rgb; return rgb;
} }
void framecatcher::getXineError(int errorCode, std::string& errorStr){ void framecatcher::getError(int errorCode, std::string& errorStr){
switch (errorCode){ switch (errorCode){
case XINE_ERROR_NO_INPUT_PLUGIN: case XINE_ERROR_NO_INPUT_PLUGIN:

View File

@ -58,17 +58,19 @@ public:
*/ */
void close(); void close();
void getError(int errCode, std::string& errStr);
private: private:
xine_t *xine; xine_t *xine;
static xine_stream_t *stream; xine_stream_t *stream;
xine_video_port_t *vo_port; xine_video_port_t *vo_port;
std::string vo_driver; std::string vo_driver;
std::string codec;
int length; // length of the stream int length; // length of the stream
void getXineError(int errCode, std::string& errStr);
void yuy2Toyv12 (uint8_t *, uint8_t *, uint8_t *, uint8_t *, int , int ); void yuy2Toyv12 (uint8_t *, uint8_t *, uint8_t *, uint8_t *, int , int );
unsigned char * yv12ToRgb (uint8_t *, uint8_t *, uint8_t *, int , int ); unsigned char * yv12ToRgb (uint8_t *, uint8_t *, uint8_t *, int , int );