mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
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:
parent
b0aa255ead
commit
a9ee3d92dc
@ -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
|
||||
|
||||
TEMPLATE = app
|
||||
@ -669,6 +669,20 @@ SOURCES += idle/idle.cpp \
|
||||
idle/idle_platform.cpp
|
||||
}
|
||||
|
||||
framecatcher {
|
||||
|
||||
HEADERS += util/framecatcher.h
|
||||
|
||||
SOURCES += util/framecatcher.cpp
|
||||
|
||||
LIBS += -lxine
|
||||
|
||||
DEFINES *= CHANNELS_FRAME_CATCHER
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
minimal {
|
||||
SOURCES = main.cpp \
|
||||
rshare.cpp \
|
||||
|
@ -37,7 +37,7 @@
|
||||
|
||||
/** Constructor */
|
||||
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 */
|
||||
setupUi(this);
|
||||
@ -50,7 +50,10 @@ CreateChannelMsg::CreateChannelMsg(std::string cId)
|
||||
connect(addFileButton, SIGNAL(clicked() ), this , SLOT(addExtraFile()));
|
||||
connect(addfilepushButton, SIGNAL(clicked() ), this , SLOT(addExtraFile()));
|
||||
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);
|
||||
|
||||
setAcceptDrops(true);
|
||||
@ -58,6 +61,14 @@ CreateChannelMsg::CreateChannelMsg(std::string cId)
|
||||
newChannelMsg();
|
||||
}
|
||||
|
||||
CreateChannelMsg::~CreateChannelMsg(){
|
||||
|
||||
#ifdef CHANNELS_FRAME_CATCHER
|
||||
delete fCatcher;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/* Dropping */
|
||||
|
||||
void CreateChannelMsg::dragEnterEvent(QDragEnterEvent *event)
|
||||
@ -299,6 +310,9 @@ void CreateChannelMsg::addAttachment(const std::string &path)
|
||||
std::cerr << "CreateChannelMsg::addAttachment()";
|
||||
std::cerr << std::endl;
|
||||
|
||||
if(mAutoMediaThumbNail)
|
||||
setThumbNail(path, 2000);
|
||||
|
||||
/* add widget in for new destination */
|
||||
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()
|
||||
{
|
||||
std::list<SubFileItem *>::iterator fit;
|
||||
|
@ -25,6 +25,10 @@
|
||||
#include "ui_CreateChannelMsg.h"
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef CHANNELS_FRAME_CATCHER
|
||||
#include "util/framecatcher.h"
|
||||
#endif
|
||||
|
||||
class SubFileItem;
|
||||
class FileInfo;
|
||||
|
||||
@ -35,7 +39,10 @@ class CreateChannelMsg : public QDialog, private Ui::CreateChannelMsg
|
||||
public:
|
||||
/** Default Constructor */
|
||||
CreateChannelMsg(std::string cId);
|
||||
|
||||
|
||||
/** Default Destructor */
|
||||
~CreateChannelMsg();
|
||||
|
||||
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);
|
||||
@ -56,18 +63,26 @@ private slots:
|
||||
void sendMsg();
|
||||
|
||||
void addThumbnail();
|
||||
void allowAutoMediaThumbNail(bool);
|
||||
|
||||
private:
|
||||
|
||||
void parseRsFileListAttachments(const std::string &attachList);
|
||||
|
||||
void sendMessage(std::wstring subject, std::wstring msg, std::list<FileInfo> &files);
|
||||
bool setThumbNail(const std::string& path, int frame);
|
||||
|
||||
|
||||
std::string mChannelId;
|
||||
|
||||
std::list<SubFileItem *> mAttachments;
|
||||
|
||||
bool mCheckAttachment;
|
||||
bool mAutoMediaThumbNail;
|
||||
|
||||
#ifdef CHANNELS_FRAME_CATCHER
|
||||
framecatcher* fCatcher;
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>509</width>
|
||||
<height>464</height>
|
||||
<height>479</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="acceptDrops">
|
||||
@ -97,7 +97,7 @@ p, li { white-space: pre-wrap; }
|
||||
<item row="0" column="0">
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>1</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
@ -248,25 +248,8 @@ p, li { white-space: pre-wrap; }
|
||||
<attribute name="title">
|
||||
<string>Attachments</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="spacing">
|
||||
<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>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string/>
|
||||
@ -276,7 +259,7 @@ p, li { white-space: pre-wrap; }
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
@ -295,7 +278,7 @@ p, li { white-space: pre-wrap; }
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<item row="0" column="2">
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
@ -308,7 +291,7 @@ p, li { white-space: pre-wrap; }
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QPushButton" name="addFileButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
@ -337,9 +320,17 @@ p, li { white-space: pre-wrap; }
|
||||
</property>
|
||||
</widget>
|
||||
</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 row="1" column="0" colspan="5">
|
||||
<widget class="QScrollArea" name="scrollArea">
|
||||
<property name="verticalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOn</enum>
|
||||
@ -352,8 +343,8 @@ p, li { white-space: pre-wrap; }
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>464</width>
|
||||
<height>282</height>
|
||||
<width>456</width>
|
||||
<height>251</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
|
@ -306,7 +306,7 @@ unsigned char * framecatcher::yv12ToRgb (uint8_t *src_y, uint8_t *src_u, uint8_t
|
||||
return rgb;
|
||||
}
|
||||
|
||||
void framecatcher::getXineError(int errorCode, std::string& errorStr){
|
||||
void framecatcher::getError(int errorCode, std::string& errorStr){
|
||||
|
||||
switch (errorCode){
|
||||
case XINE_ERROR_NO_INPUT_PLUGIN:
|
||||
|
@ -58,17 +58,19 @@ public:
|
||||
*/
|
||||
void close();
|
||||
|
||||
void getError(int errCode, std::string& errStr);
|
||||
|
||||
private:
|
||||
|
||||
xine_t *xine;
|
||||
static xine_stream_t *stream;
|
||||
xine_stream_t *stream;
|
||||
xine_video_port_t *vo_port;
|
||||
std::string vo_driver;
|
||||
|
||||
std::string codec;
|
||||
|
||||
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 );
|
||||
unsigned char * yv12ToRgb (uint8_t *, uint8_t *, uint8_t *, int , int );
|
||||
|
Loading…
Reference in New Issue
Block a user