Browse Source

Add usb0 to usb3 to media server locations

master
Krisjanis Rijnieks 9 years ago
parent
commit
c83c001967
  1. 69
      src/MediaServer/MediaServer.cpp
  2. 48
      src/MediaServer/MediaServer.h

69
src/MediaServer/MediaServer.cpp

@ -11,11 +11,20 @@
namespace ofx {
namespace piMapper {
MediaServer::MediaServer() :
MediaServer::MediaServer():
videoWatcher(ofToDataPath(DEFAULT_VIDEOS_DIR, true), SourceType::SOURCE_TYPE_VIDEO),
piVideoWatcher(PI_IMAGES_DIR, SourceType::SOURCE_TYPE_VIDEO),
usb0VideoWatcher(USB0_VIDEOS_DIR, SourceType::SOURCE_TYPE_VIDEO),
usb1VideoWatcher(USB1_VIDEOS_DIR, SourceType::SOURCE_TYPE_VIDEO),
usb2VideoWatcher(USB2_VIDEOS_DIR, SourceType::SOURCE_TYPE_VIDEO),
usb3VideoWatcher(USB3_VIDEOS_DIR, SourceType::SOURCE_TYPE_VIDEO),
imageWatcher(ofToDataPath(DEFAULT_IMAGES_DIR, true), SourceType::SOURCE_TYPE_IMAGE),
piVideoWatcher(PI_IMAGES_DIR, SourceType::SOURCE_TYPE_VIDEO),
piImageWatcher(PI_IMAGES_DIR, SourceType::SOURCE_TYPE_IMAGE){
piImageWatcher(PI_IMAGES_DIR, SourceType::SOURCE_TYPE_IMAGE),
usb0ImageWatcher(USB0_IMAGES_DIR, SourceType::SOURCE_TYPE_IMAGE),
usb1ImageWatcher(USB1_IMAGES_DIR, SourceType::SOURCE_TYPE_IMAGE),
usb2ImageWatcher(USB2_IMAGES_DIR, SourceType::SOURCE_TYPE_IMAGE),
usb3ImageWatcher(USB3_IMAGES_DIR, SourceType::SOURCE_TYPE_IMAGE)
{
addWatcherListeners();
}
@ -26,13 +35,37 @@ MediaServer::~MediaServer(){
int MediaServer::getNumImages(){
int numLocalImages = imageWatcher.getFilePaths().size();
int numPiImages = piImageWatcher.getFilePaths().size();
int sum = numLocalImages + numPiImages;
int numUsb0Images = usb0ImageWatcher.getFilePaths().size();
int numUsb1Images = usb1ImageWatcher.getFilePaths().size();
int numUsb2Images = usb2ImageWatcher.getFilePaths().size();
int numUsb3Images = usb3ImageWatcher.getFilePaths().size();
int sum =
numLocalImages +
numPiImages +
numUsb0Images +
numUsb1Images +
numUsb2Images +
numUsb3Images;
return sum;
}
int MediaServer::getNumVideos(){
int numLocalVideos = videoWatcher.getFilePaths().size();
int numPiVideos = piVideoWatcher.getFilePaths().size();
int sum = numLocalVideos + numPiVideos;
int numUsb0Videos = usb0VideoWatcher.getFilePaths().size();
int numUsb1Videos = usb1VideoWatcher.getFilePaths().size();
int numUsb2Videos = usb2VideoWatcher.getFilePaths().size();
int numUsb3Videos = usb3VideoWatcher.getFilePaths().size();
int sum =
numLocalVideos +
numPiVideos +
numUsb0Videos +
numUsb1Videos +
numUsb2Videos +
numUsb3Videos;
return sum;
}
int MediaServer::getNumFboSources(){
@ -40,12 +73,21 @@ int MediaServer::getNumFboSources(){
}
vector <string> & MediaServer::getImagePaths(){
vector <string> & localPaths = imageWatcher.getFilePaths();
vector <string> & piPaths = piImageWatcher.getFilePaths();
vector<string> & localPaths = imageWatcher.getFilePaths();
vector<string> & piPaths = piImageWatcher.getFilePaths();
vector<string> & usb0Paths = usb0ImageWatcher.getFilePaths();
vector<string> & usb1Paths = usb1ImageWatcher.getFilePaths();
vector<string> & usb2Paths = usb2ImageWatcher.getFilePaths();
vector<string> & usb3Paths = usb3ImageWatcher.getFilePaths();
_tempImagePaths.clear();
_tempImagePaths.insert(_tempImagePaths.end(), localPaths.begin(), localPaths.end());
_tempImagePaths.insert(_tempImagePaths.end(), piPaths.begin(), piPaths.end());
_tempImagePaths.insert(_tempImagePaths.end(), usb0Paths.begin(), usb0Paths.end());
_tempImagePaths.insert(_tempImagePaths.end(), usb1Paths.begin(), usb1Paths.end());
_tempImagePaths.insert(_tempImagePaths.end(), usb2Paths.begin(), usb2Paths.end());
_tempImagePaths.insert(_tempImagePaths.end(), usb3Paths.begin(), usb3Paths.end());
return _tempImagePaths;
}
@ -71,12 +113,21 @@ vector <string> MediaServer::getFboSourceNames(){
}
vector <string> & MediaServer::getVideoPaths(){
vector <string> & localPaths = videoWatcher.getFilePaths();
vector <string> & piPaths = piVideoWatcher.getFilePaths();
vector<string> & localPaths = videoWatcher.getFilePaths();
vector<string> & piPaths = piVideoWatcher.getFilePaths();
vector<string> & usb0Paths = usb0VideoWatcher.getFilePaths();
vector<string> & usb1Paths = usb1VideoWatcher.getFilePaths();
vector<string> & usb2Paths = usb2VideoWatcher.getFilePaths();
vector<string> & usb3Paths = usb3VideoWatcher.getFilePaths();
_tempVideoPaths.clear();
_tempVideoPaths.insert(_tempVideoPaths.begin(), localPaths.begin(), localPaths.end());
_tempVideoPaths.insert(_tempVideoPaths.begin(), piPaths.begin(), piPaths.end());
_tempVideoPaths.insert(_tempVideoPaths.begin(), usb0Paths.begin(), usb0Paths.end());
_tempVideoPaths.insert(_tempVideoPaths.begin(), usb1Paths.begin(), usb1Paths.end());
_tempVideoPaths.insert(_tempVideoPaths.begin(), usb2Paths.begin(), usb2Paths.end());
_tempVideoPaths.insert(_tempVideoPaths.begin(), usb3Paths.begin(), usb3Paths.end());
return _tempVideoPaths;
}

48
src/MediaServer/MediaServer.h

@ -18,7 +18,8 @@
/* Discussion: This could be the right place for a Factory Method or
* Abstract Factory design pattern - replace all these includes with a
* SourceFactory that can create sources with the interfaces below. */
* SourceFactory that can create sources with the interfaces below.
*/
#include "BaseSource.h"
#include "ImageSource.h"
#include "VideoSource.h"
@ -31,6 +32,32 @@
#define PI_IMAGES_DIR "/boot/ofxpimapper/sources/images"
#define PI_VIDEOS_DIR "/boot/ofxpimapper/sources/videos"
/*
* These you can get when you apt-get install usbmount
*/
#define USB0_IMAGES_DIR "/media/usb0"
#define USB1_IMAGES_DIR "/media/usb1"
#define USB2_IMAGES_DIR "/media/usb2"
#define USB3_IMAGES_DIR "/media/usb3"
#define USB0_VIDEOS_DIR "/media/usb0"
#define USB1_VIDEOS_DIR "/media/usb1"
#define USB2_VIDEOS_DIR "/media/usb2"
#define USB3_VIDEOS_DIR "/media/usb3"
// TODO: Change this into a externally configurable list
/*
Considering that the pi has 4 USB ports, there is a possibility to connect 4 USB flash drives. The paths to them would be
/media/usb0
/media/usb1
/media/usb2
/media/usb3
We need all of them and we search for mp4, jpg and png files there.
*/
namespace ofx {
namespace piMapper {
@ -84,11 +111,20 @@ class MediaServer {
private:
// Directory Watchers
ofx::piMapper::DirectoryWatcher videoWatcher;
ofx::piMapper::DirectoryWatcher imageWatcher;
ofx::piMapper::DirectoryWatcher piVideoWatcher;
ofx::piMapper::DirectoryWatcher piImageWatcher;
DirectoryWatcher videoWatcher;
DirectoryWatcher piVideoWatcher;
DirectoryWatcher usb0VideoWatcher;
DirectoryWatcher usb1VideoWatcher;
DirectoryWatcher usb2VideoWatcher;
DirectoryWatcher usb3VideoWatcher;
DirectoryWatcher imageWatcher;
DirectoryWatcher piImageWatcher;
DirectoryWatcher usb0ImageWatcher;
DirectoryWatcher usb1ImageWatcher;
DirectoryWatcher usb2ImageWatcher;
DirectoryWatcher usb3ImageWatcher;
vector <string> _tempImagePaths;
vector <string> _tempVideoPaths;

Loading…
Cancel
Save