CodyCam: Style Fixes, Make Resource File Verbose

No functional change intended, added some copyrights
in the process.

Change-Id: Ic6ebe276bb939c425d65aff1b3b07c7c2e27a33a
Reviewed-on: https://review.haiku-os.org/c/1698
Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
CodeforEvolution
2019-08-10 17:57:03 +00:00
committed by waddlesplash
parent f5953f6155
commit 6a739773fc
15 changed files with 579 additions and 417 deletions
+19 -9
View File
@@ -1,3 +1,10 @@
/*
* Copyright 1998-1999 Be, Inc. All Rights Reserved.
* Copyright 2003-2019 Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#include "CodyCam.h"
#include <stdio.h>
@@ -23,6 +30,7 @@
#include <TextControl.h>
#include <TimeSource.h>
#include <TranslationUtils.h>
#include <TranslatorFormats.h>
#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "CodyCam"
@@ -233,7 +241,7 @@ CodyCam::_SetUpNodes()
fVideoConsumer = new VideoConsumer("CodyCam",
((VideoWindow*)fWindow)->VideoView(),
((VideoWindow*)fWindow)->StatusLine(), NULL, 0);
if (!fVideoConsumer) {
if (fVideoConsumer == NULL) {
fWindow->ErrorAlert(B_TRANSLATE("Cannot create a video window"),
B_ERROR);
return B_ERROR;
@@ -254,8 +262,8 @@ CodyCam::_SetUpNodes()
&cnt, B_MEDIA_RAW_VIDEO);
if (status != B_OK || cnt < 1) {
status = B_RESOURCE_UNAVAILABLE;
fWindow->ErrorAlert(B_TRANSLATE("Cannot find an available video stream"),
status);
fWindow->ErrorAlert(
B_TRANSLATE("Cannot find an available video stream"), status);
return status;
}
@@ -369,7 +377,7 @@ void
CodyCam::_TearDownNodes()
{
CALL("CodyCam::_TearDownNodes\n");
if (!fMediaRoster)
if (fMediaRoster == NULL)
return;
if (fVideoConsumer) {
@@ -515,7 +523,7 @@ VideoWindow::MessageReceived(BMessage* message)
FTPINFO("never\n");
fFtpInfo.rate = (bigtime_t)(B_INFINITE_TIMEOUT);
} else {
FTPINFO("%ld seconds\n", (long)seconds);
FTPINFO("%" B_PRId32 " seconds\n", seconds);
fFtpInfo.rate = (bigtime_t)(seconds * 1000000LL);
}
break;
@@ -627,7 +635,8 @@ VideoWindow::_BuildCaptureControls()
// format menu
fImageFormatMenu = new BPopUpMenu(B_TRANSLATE("Image Format Menu"));
BTranslationUtils::AddTranslationItems(fImageFormatMenu, B_TRANSLATOR_BITMAP);
BTranslationUtils::AddTranslationItems(fImageFormatMenu,
B_TRANSLATOR_BITMAP);
fImageFormatMenu->SetTargetForItems(this);
if (fImageFormatSettings->Value()
@@ -843,7 +852,8 @@ VideoWindow::_QuitSettings()
fFilenameSetting->ValueChanged(fFileName->Text());
fImageFormatSettings->ValueChanged(fImageFormatMenu->FindMarked()->Label());
fCaptureRateSetting->ValueChanged(fCaptureRateMenu->FindMarked()->Label());
fUploadClientSetting->ValueChanged(fUploadClientMenu->FindMarked()->Label());
fUploadClientSetting->ValueChanged(
fUploadClientMenu->FindMarked()->Label());
fSettings->SaveSettings();
delete fSettings;
@@ -933,9 +943,9 @@ ControlWindow::QuitRequested()
// #pragma mark -
int main() {
int main()
{
CodyCam app;
app.Run();
return 0;
}
+8 -4
View File
@@ -1,10 +1,12 @@
/*
* Copyright 1998-1999 Be, Inc. All Rights Reserved.
* Copyright 2003-2019 Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef CODYCAM_H
#define CODYCAM_H
#include "Settings.h"
#include "VideoConsumer.h"
#include <string.h>
#include <Application.h>
@@ -18,6 +20,9 @@
#include <TextControl.h>
#include <Window.h>
#include "Settings.h"
#include "VideoConsumer.h"
class BMediaRoster;
@@ -194,4 +199,3 @@ private:
};
#endif // CODYCAM_H
+13 -28
View File
@@ -1,7 +1,7 @@
resource(1, "BEOS:FILE_TYPES") message;
resource file_types message;
resource vector_icon {
resource vector_icon array {
$"6E6369660B03010000020002023A00000000000000004000004BC00000000000"
$"010000FFFF01000000020006023CC0000000000000003D000048000048800040"
$"010101FFC1ACAC040168020106023A26EC38CA29B828213953DB48968D4B2BC6"
@@ -27,31 +27,16 @@ resource app_signature "application/x-vnd.Haiku-CodyCam";
resource app_name_catalog_entry "x-vnd.Haiku-CodyCam:System name:CodyCam";
resource(1, "BEOS:APP_VERSION") #'APPV' array
{
$"0100000000000000000000000000000001000000312E30643100000000000000"
$"0000000000000000000000000000000000000000000000000000000000000000"
$"000000000000000000000000000000000000000052342E3520C2A9313939312D"
$"3139393920426520496E636F72706F7261746564000000000000000000000000"
$"0000000000000000000000000000000000000000000000000000000000000000"
$"0000000000000000000000000000000000000000000000000000000000000000"
$"0000000000000000000000000000000000000000000000000000000000000000"
$"0000000000000000000000000000000000000000000000000000000000000000"
$"0000000000000000000000000000000000000000000000000000000000000000"
$"0000000000000000000000000000000000000000000000000000000000000000"
$"0000000000000000000000000000000000000000000000000000000000000000"
$"0000000000000000000000000000000000000000000000000000000000000000"
$"0000000000000000000000000000000000000000000000000000000000000000"
$"0000000000000000000000000000000000000000000000000000000000000000"
$"0000000000000000000000000000000000000000000000000000000000000000"
$"0000000000000000000000000000000000000000000000000000000000000000"
$"0000000000000000000000000000000000000000000000000000000000000000"
$"0000000000000000000000000000000000000000000000000000000000000000"
$"0000000000000000000000000000000000000000000000000000000000000000"
$"0000000000000000000000000000000000000000000000000000000000000000"
$"0000000000000000000000000000000000000000000000000000000000000000"
$"0000000000000000"
resource app_version {
major = 1,
middle = 0,
minor = 0,
variety = B_APPV_DEVELOPMENT,
internal = 1,
short_info = "1.0d1",
long_info = "©1991-1999 Be, Inc., ©2003-2019 Haiku, Inc."
};
resource(1, "BEOS:APP_FLAGS") #'APPF' $"00000000";
resource app_flags B_SINGLE_LAUNCH;
+22 -21
View File
@@ -1,5 +1,13 @@
/*
* Copyright 1998-1999 Be, Inc. All Rights Reserved.
* Copyright 2003-2019 Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#include "FileUploadClient.h"
FileUploadClient::FileUploadClient()
{
}
@@ -13,48 +21,45 @@ FileUploadClient::~FileUploadClient()
bool
FileUploadClient::ChangeDir(const string& dir)
{
bool rc = false;
return rc;
return false;
}
bool
FileUploadClient::ListDirContents(string& listing)
{
bool rc = false;
return rc;
return false;
}
bool
FileUploadClient::PrintWorkingDir(string& dir)
{
bool rc = false;
return rc;
return false;
}
bool
FileUploadClient::Connect(const string& server, const string& login, const string& passwd)
FileUploadClient::Connect(const string& server, const string& login,
const string& passwd)
{
bool rc = false;
return rc;
return false;
}
bool
FileUploadClient::PutFile(const string& local, const string& remote, ftp_mode mode)
FileUploadClient::PutFile(const string& local, const string& remote,
ftp_mode mode)
{
bool rc = false;
return rc;
return false;
}
bool
FileUploadClient::GetFile(const string& remote, const string& local, ftp_mode mode)
FileUploadClient::GetFile(const string& remote, const string& local,
ftp_mode mode)
{
bool rc = false;
return rc;
return false;
}
@@ -63,16 +68,14 @@ FileUploadClient::GetFile(const string& remote, const string& local, ftp_mode mo
bool
FileUploadClient::MoveFile(const string& oldPath, const string& newPath)
{
bool rc = false;
return rc;
return false;
}
bool
FileUploadClient::Chmod(const string& path, const string& mod)
{
bool rc = false;
return rc;
return false;
}
@@ -80,5 +83,3 @@ void
FileUploadClient::SetPassive(bool on)
{
}
+13 -4
View File
@@ -1,3 +1,8 @@
/*
* Copyright 1998-1999 Be, Inc. All Rights Reserved.
* Copyright 2003-2019 Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef FILE_UPLOAD_CLIENT_H
#define FILE_UPLOAD_CLIENT_H
@@ -18,16 +23,20 @@ virtual ~FileUploadClient();
ascii_mode
};
virtual bool Connect(const string& server, const string& login,
virtual bool Connect(const string& server,
const string& login,
const string& passwd);
virtual bool PutFile(const string& local, const string& remote,
virtual bool PutFile(const string& local,
const string& remote,
ftp_mode mode = binary_mode);
virtual bool GetFile(const string& remote, const string& local,
virtual bool GetFile(const string& remote,
const string& local,
ftp_mode mode = binary_mode);
virtual bool MoveFile(const string& oldPath, const string& newPath);
virtual bool MoveFile(const string& oldPath,
const string& newPath);
virtual bool ChangeDir(const string& dir);
virtual bool PrintWorkingDir(string& dir);
virtual bool ListDirContents(string& listing);
+47 -23
View File
@@ -1,3 +1,10 @@
/*
* Copyright 1998-1999 Be, Inc. All Rights Reserved.
* Copyright 2003-2019 Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#include "FtpClient.h"
#include <stdlib.h>
@@ -12,7 +19,8 @@
FtpClient::FtpClient()
: FileUploadClient(),
:
FileUploadClient(),
fState(0),
fControl(NULL),
fData(NULL)
@@ -32,7 +40,8 @@ FtpClient::ChangeDir(const string& dir)
{
bool rc = false;
int code, codeType;
string cmd = "CWD ", replyString;
string cmd = "CWD ";
string replyString;
cmd += dir;
@@ -87,7 +96,7 @@ FtpClient::ListDirContents(string& listing)
}
delete fData;
fData = 0;
fData = NULL;
return rc;
}
@@ -98,7 +107,8 @@ FtpClient::PrintWorkingDir(string& dir)
{
bool rc = false;
int code, codeType;
string cmd = "PWD", replyString;
string cmd = "PWD";
string replyString;
long i;
if (_SendRequest(cmd) == true) {
@@ -119,7 +129,8 @@ FtpClient::PrintWorkingDir(string& dir)
bool
FtpClient::Connect(const string& server, const string& login, const string& passwd)
FtpClient::Connect(const string& server, const string& login,
const string& passwd)
{
bool rc = false;
int code, codeType;
@@ -129,7 +140,7 @@ FtpClient::Connect(const string& server, const string& login, const string& pass
delete fControl;
delete fData;
fControl = new BNetEndpoint;
fControl = new BNetEndpoint();
if (fControl->InitCheck() != B_NO_ERROR)
return false;
@@ -174,7 +185,7 @@ FtpClient::Connect(const string& server, const string& login, const string& pass
_SetState(ftp_connected);
else {
delete fControl;
fControl = 0;
fControl = NULL;
}
return rc;
@@ -188,7 +199,9 @@ FtpClient::PutFile(const string& local, const string& remote, ftp_mode mode)
string cmd, replyString;
int code, codeType, rlen, slen, i;
BFile infile(local.c_str(), B_READ_ONLY);
char buf[8192], sbuf[16384], *stmp;
char buf[8192];
char sbuf[16384];
char* stmp;
if (infile.InitCheck() != B_NO_ERROR)
return false;
@@ -251,7 +264,7 @@ FtpClient::PutFile(const string& local, const string& remote, ftp_mode mode)
}
delete fData;
fData = 0;
fData = NULL;
if (rc) {
_GetReply(replyString, code, codeType);
@@ -269,7 +282,9 @@ FtpClient::GetFile(const string& remote, const string& local, ftp_mode mode)
string cmd, replyString;
int code, codeType, rlen, slen, i;
BFile outfile(local.c_str(), B_READ_WRITE | B_CREATE_FILE);
char buf[8192], sbuf[16384], *stmp;
char buf[8192];
char sbuf[16384];
char* stmp;
bool writeError = false;
if (outfile.InitCheck() != B_NO_ERROR)
@@ -328,7 +343,7 @@ FtpClient::GetFile(const string& remote, const string& local, ftp_mode mode)
}
delete fData;
fData = 0;
fData = NULL;
if (rc) {
_GetReply(replyString, code, codeType);
@@ -373,7 +388,8 @@ FtpClient::Chmod(const string& path, const string& mod)
{
bool rc = false;
int code, codeType;
string cmd = "SITE CHMOD ", replyString;
string cmd = "SITE CHMOD ";
string replyString;
cmd += mod;
cmd += " ";
@@ -382,6 +398,7 @@ FtpClient::Chmod(const string& path, const string& mod)
if (path.length() == 0)
cmd += '/';
printf(B_TRANSLATE("cmd: '%s'\n"), cmd.c_str());
if (_SendRequest(cmd) == true) {
if (_GetReply(replyString, code, codeType) == true) {
printf(B_TRANSLATE("reply: %d, %d\n"), code, codeType);
@@ -452,9 +469,10 @@ FtpClient::_GetReplyLine(string& line)
int c = 0;
bool done = false;
line = ""; // Thanks to Stephen van Egmond for catching a bug here
line = "";
// Thanks to Stephen van Egmond for catching a bug here
if (fControl != 0) {
if (fControl != NULL) {
rc = true;
while (done == false && fControl->Receive(&c, 1) > 0) {
if (c == EOF || c == xEOF || c == '\n') {
@@ -528,7 +546,8 @@ FtpClient::_GetReply(string& outString, int& outCode, int& codeType)
* 123 The last line
*/
if ((rc = _GetReplyLine(line)) == true) {
rc = _GetReplyLine(line);
if (rc == true) {
outString = line;
outString += '\n';
printf(outString.c_str());
@@ -536,13 +555,16 @@ FtpClient::_GetReply(string& outString, int& outCode, int& codeType)
outCode = atoi(tempString.c_str());
if (line[3] == '-') {
while ((rc = _GetReplyLine(line)) == true) {
rc = _GetReplyLine(line);
while (rc == true) {
outString += line;
outString += '\n';
printf(outString.c_str());
// we're done with nnn when we get to a "nnn blahblahblah"
if ((line.find(tempString) == 0) && line[3] == ' ')
break;
rc = _GetReplyLine(line);
}
}
}
@@ -554,7 +576,7 @@ FtpClient::_GetReply(string& outString, int& outCode, int& codeType)
if (outCode == 421) {
delete fControl;
fControl = 0;
fControl = NULL;
_ClearState(ftp_connected);
}
@@ -575,9 +597,9 @@ FtpClient::_OpenDataConnection()
struct sockaddr_in sa;
delete fData;
fData = 0;
fData = NULL;
fData = new BNetEndpoint;
fData = new BNetEndpoint();
if (_TestState(ftp_passive)) {
// Here we send a "pasv" command and connect to the remote server
@@ -595,11 +617,13 @@ FtpClient::_OpenDataConnection()
i = replyString.find('(');
i++;
replyString = replyString.substr(i, replyString.find(')') - i);
replyString = replyString.substr(i,
replyString.find(')') - i);
if (sscanf(replyString.c_str(), "%d,%d,%d,%d,%d,%d",
&paddr[0], &paddr[1], &paddr[2], &paddr[3],
&paddr[4], &paddr[5]) != 6) {
// cannot do passive. Do a little harmless rercursion here
// Cannot do passive.
// Do a little harmless rercursion here.
_ClearState(ftp_passive);
return _OpenDataConnection();
}
@@ -661,9 +685,9 @@ FtpClient::_AcceptDataConnection()
bool rc = false;
if (_TestState(ftp_passive) == false) {
if (fData != 0) {
if (fData != NULL) {
endPoint = fData->Accept();
if (endPoint != 0) {
if (endPoint != NULL) {
delete fData;
fData = endPoint;
rc = true;
+18 -6
View File
@@ -1,3 +1,8 @@
/*
* Copyright 1998-1999 Be, Inc. All Rights Reserved.
* Copyright 2003-2019 Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef FTP_CLIENT_H
#define FTP_CLIENT_H
@@ -6,7 +11,9 @@
#include <string>
#include <File.h>
#include <NetworkKit.h>
#include <NetAddress.h>
#include <NetEndpoint.h>
#include "FileUploadClient.h"
using std::string;
@@ -28,16 +35,20 @@ class FtpClient : public FileUploadClient {
FtpClient();
~FtpClient();
bool Connect(const string& server, const string& login,
bool Connect(const string& server,
const string& login,
const string& passwd);
bool PutFile(const string& local, const string& remote,
bool PutFile(const string& local,
const string& remote,
ftp_mode mode = binary_mode);
bool GetFile(const string& remote, const string& local,
bool GetFile(const string& remote,
const string& local,
ftp_mode mode = binary_mode);
bool MoveFile(const string& oldPath, const string& newPath);
bool MoveFile(const string& oldPath,
const string& newPath);
bool ChangeDir(const string& dir);
bool PrintWorkingDir(string& dir);
bool ListDirContents(string& listing);
@@ -57,7 +68,8 @@ class FtpClient : public FileUploadClient {
void _ClearState(unsigned long state);
bool _SendRequest(const string& cmd);
bool _GetReply(string& outString, int& outCode, int& codeType);
bool _GetReply(string& outString, int& outCode,
int& codeType);
bool _GetReplyLine(string& line);
bool _OpenDataConnection();
bool _AcceptDataConnection();
+17 -8
View File
@@ -1,3 +1,10 @@
/*
* Copyright 1998-1999 Be, Inc. All Rights Reserved.
* Copyright 2003-2019 Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#include "Settings.h"
#include <stdio.h>
@@ -73,7 +80,7 @@ StringValueSetting::NeedsSaving() const
const char*
StringValueSetting::Handle(const char* const *argv)
{
if (!*++argv)
if (*++argv == NULL)
return fValueExpectedErrorString;
ValueChanged(*argv);
@@ -110,7 +117,7 @@ EnumeratedStringValueSetting::ValueChanged(const char* newValue)
const char*
EnumeratedStringValueSetting::Handle(const char* const *argv)
{
if (!*++argv)
if (*++argv == NULL)
return fValueExpectedErrorString;
printf("---EnumeratedStringValueSetting::Handle %s %s\n", *(argv-1), *argv);
@@ -127,7 +134,7 @@ EnumeratedStringValueSetting::_ValidateString(const char* string)
{
for (int32 i = 0;; i++) {
const char* enumString = fEnumerator(i);
if (!enumString)
if (enumString == NULL)
return false;
if (strcmp(enumString, string) == 0)
return true;
@@ -142,7 +149,8 @@ EnumeratedStringValueSetting::_ValidateString(const char* string)
ScalarValueSetting::ScalarValueSetting(const char* name, int32 defaultValue,
const char* valueExpectedErrorString, const char* wrongValueErrorString,
int32 min, int32 max)
: SettingsArgvDispatcher(name),
:
SettingsArgvDispatcher(name),
fDefaultValue(defaultValue),
fValue(defaultValue),
fMax(max),
@@ -184,7 +192,7 @@ ScalarValueSetting::GetValueAsString(char* buffer) const
const char*
ScalarValueSetting::Handle(const char* const *argv)
{
if (!*++argv)
if (*++argv == NULL)
return fValueExpectedErrorString;
int32 newValue = atoi(*argv);
@@ -199,7 +207,7 @@ ScalarValueSetting::Handle(const char *const *argv)
void
ScalarValueSetting::SaveSettingValue(Settings* settings)
{
settings->Write("%d", fValue);
settings->Write("%" B_PRId32, fValue);
}
@@ -214,7 +222,8 @@ ScalarValueSetting::NeedsSaving() const
BooleanValueSetting::BooleanValueSetting(const char* name, bool defaultValue)
: ScalarValueSetting(name, defaultValue, 0, 0)
:
ScalarValueSetting(name, defaultValue, 0, 0)
{
}
@@ -234,7 +243,7 @@ BooleanValueSetting::Value() const
const char*
BooleanValueSetting::Handle(const char* const *argv)
{
if (!*++argv) {
if (*++argv == NULL) {
return B_TRANSLATE_COMMENT("on or off expected","Do not translate "
"'on' and 'off'");
}
+7 -1
View File
@@ -1,3 +1,8 @@
/*
* Copyright 1998-1999 Be, Inc. All Rights Reserved.
* Copyright 2003-2019 Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef SETTINGS_H
#define SETTINGS_H
@@ -61,7 +66,8 @@ public:
int32 defaultValue,
const char* valueExpectedErrorString,
const char* wrongValueErrorString,
int32 min = INT32_MIN, int32 max = INT32_MAX);
int32 min = INT32_MIN,
int32 max = INT32_MAX);
virtual ~ScalarValueSetting();
void ValueChanged(int32 newValue);
+76 -41
View File
@@ -1,10 +1,20 @@
#include <String.h>
#include <unistd.h>
/*
* Copyright 1998-1999 Be, Inc. All Rights Reserved.
* Copyright 2003-2019 Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#include "SftpClient.h"
#include <unistd.h>
#include <String.h>
SftpClient::SftpClient()
: SpawningUploadClient()
:
SpawningUploadClient()
{
}
@@ -19,33 +29,37 @@ SftpClient::~SftpClient()
bool
SftpClient::ChangeDir(const string& dir)
{
bool rc = false;
int len;
BString cmd("cd");
BString reply;
cmd << " " << dir.c_str() << "\n";
SendCommand(cmd.String());
if ((len = ReadReply(&reply)) < 0) {
len = ReadReply(&reply);
if (len < 0) {
fprintf(stderr, _GetReadText(), len);
return false;
}
fprintf(stderr, _GetReplyText(), reply.String());
if (reply.FindFirst("sftp>") < 0)
return false;
rc = true;
return rc;
return true;
}
bool
SftpClient::ListDirContents(string& listing)
{
bool rc = false;
int len;
SendCommand("ls\n");
BString reply;
SendCommand("ls\n");
do {
if ((len = ReadReply(&reply)) < 0) {
len = ReadReply(&reply);
if (len < 0) {
fprintf(stderr, _GetReadText(), len);
return false;
}
@@ -54,17 +68,16 @@ SftpClient::ListDirContents(string& listing)
if (reply.FindFirst("sftp>") == 0)
return true;
} while (true);
return rc;
return false;
}
bool
SftpClient::PrintWorkingDir(string& dir)
{
bool rc = false;
SendCommand("pwd\n");
BString reply;
return rc;
return false;
}
@@ -72,24 +85,30 @@ bool
SftpClient::Connect(const string& server, const string& login,
const string& passwd)
{
bool rc = false;
BString cmd("sftp ");
BString host(server.c_str());
BString port;
if (host.FindFirst(':'))
host.MoveInto(port, host.FindFirst(':'), host.Length());
port.RemoveAll(":");
if (port.Length())
cmd << "-oPort=" << port << " ";
cmd << login.c_str();
cmd << "@" << host.String();
printf("COMMAND: '%s'\n", cmd.String());
SetCommandLine(cmd.String());
rc = SpawningUploadClient::Connect(server, login, passwd);
if (!SpawningUploadClient::Connect(server, login, passwd))
return false;
BString reply;
ssize_t len;
if ((len = ReadReply(&reply)) < 0) {
len = ReadReply(&reply);
if (len < 0) {
fprintf(stderr, _GetLongReadText(), len);
return false;
}
@@ -97,10 +116,12 @@ SftpClient::Connect(const string& server, const string& login,
if (reply.FindFirst("Connecting to ") != 0)
return false;
if ((len = ReadReply(&reply)) < 0) {
len = ReadReply(&reply);
if (len < 0) {
fprintf(stderr, _GetLongReadText(), len);
return false;
}
fprintf(stderr, _GetReplyText(), reply.String());
if (reply.FindFirst(/*[pP]*/"assword:") < 0)
return false;
@@ -108,63 +129,70 @@ SftpClient::Connect(const string& server, const string& login,
write(OutputPipe(), passwd.c_str(), strlen(passwd.c_str()));
write(OutputPipe(), "\n", 1);
if ((len = ReadReply(&reply)) < 0) {
len = ReadReply(&reply);
if (len < 0) {
fprintf(stderr, _GetLongReadText(), len);
return false;
}
fprintf(stderr, _GetReplyText(), reply.String());
if (reply != "\n")
return false;
if ((len = ReadReply(&reply)) < 0) {
len = ReadReply(&reply);
if (len < 0) {
fprintf(stderr, _GetLongReadText(), len);
return false;
}
fprintf(stderr, _GetReplyText(), reply.String());
if (reply.FindFirst("sftp>") < 0)
return false;
return rc;
return true;
}
bool
SftpClient::PutFile(const string& local, const string& remote, ftp_mode mode)
{
bool rc = false;
int len;
//XXX: handle mode ?
BString cmd("put");
cmd << " " << local.c_str() << " " << remote.c_str() << "\n";
SendCommand(cmd.String());
BString reply;
if ((len = ReadReply(&reply)) < 0) {
len = ReadReply(&reply);
if (len < 0) {
fprintf(stderr, _GetReadText(), len);
return false;
}
fprintf(stderr, _GetReplyText(), reply.String());
if (reply.FindFirst("Uploading") < 0)
return false;
if ((len = ReadReply(&reply)) < 0) {
len = ReadReply(&reply);
if (len < 0) {
fprintf(stderr, _GetReadText(), len);
return false;
}
fprintf(stderr, _GetReplyText(), reply.String());
if (reply.FindFirst("sftp>") < 0)
return false;
rc = true;
return rc;
return true;
}
bool
SftpClient::GetFile(const string& remote, const string& local, ftp_mode mode)
{
bool rc = false;
//XXX
return rc;
return false;
}
@@ -173,7 +201,6 @@ SftpClient::GetFile(const string& remote, const string& local, ftp_mode mode)
bool
SftpClient::MoveFile(const string& oldPath, const string& newPath)
{
bool rc = false;
int len;
// sftpd can't rename to an existing file...
@@ -183,19 +210,23 @@ SftpClient::MoveFile(const string& oldPath, const string& newPath)
SendCommand(cmd.String());
BString reply;
if ((len = ReadReply(&reply)) < 0) {
len = ReadReply(&reply);
if (len < 0) {
fprintf(stderr, _GetReadText(), len);
return false;
}
fprintf(stderr, _GetReplyText(), reply.String());
// we don't care if it worked or not.
//if (reply.FindFirst("Removing") != 0 && reply.FindFirst("Couldn't") )
// return false;
if ((len = ReadReply(&reply)) < 0) {
len = ReadReply(&reply);
if (len < 0) {
fprintf(stderr, _GetReadText(), len);
return false;
}
fprintf(stderr, _GetReplyText(), reply.String());
if (reply.FindFirst("sftp>") < 0)
return false;
@@ -203,47 +234,53 @@ SftpClient::MoveFile(const string& oldPath, const string& newPath)
cmd = "rename";
cmd << " " << oldPath.c_str() << " " << newPath.c_str() << "\n";
SendCommand(cmd.String());
if ((len = ReadReply(&reply)) < 0) {
len = ReadReply(&reply);
if (len < 0) {
fprintf(stderr, _GetReadText(), len);
return false;
}
fprintf(stderr, _GetReplyText(), reply.String());
if (reply.FindFirst("sftp>") < 0)
return false;
rc = true;
return rc;
return true;
}
bool
SftpClient::Chmod(const string& path, const string& mod)
{
bool rc = false;
int len;
//XXX: handle mode ?
BString cmd("chmod");
cmd << " " << mod.c_str() << " " << path.c_str() << "\n";
SendCommand(cmd.String());
BString reply;
if ((len = ReadReply(&reply)) < 0) {
len = ReadReply(&reply);
if (len < 0) {
fprintf(stderr, _GetReadText(), len);
return false;
}
fprintf(stderr, _GetReplyText(), reply.String());
if (reply.FindFirst("Changing") < 0)
return false;
if ((len = ReadReply(&reply)) < 0) {
len = ReadReply(&reply);
if (len < 0) {
fprintf(stderr, _GetReadText(), len);
return false;
}
fprintf(stderr, _GetReplyText(), reply.String());
if (reply.FindFirst("sftp>") < 0)
return false;
rc = true;
return rc;
return true;
}
@@ -272,5 +309,3 @@ SftpClient::_GetReplyText() const
{
return B_TRANSLATE("reply: '%s'\n");
}
+5
View File
@@ -1,3 +1,8 @@
/*
* Copyright 1998-1999 Be, Inc. All Rights Reserved.
* Copyright 2003-2019 Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef SFTP_CLIENT_H
#define SFTP_CLIENT_H
+37 -31
View File
@@ -1,18 +1,27 @@
#include <errno.h>
#include <image.h>
#include <unistd.h>
#include <signal.h>
#include <stdlib.h>
/*
* Copyright 1998-1999 Be, Inc. All Rights Reserved.
* Copyright 2003-2019 Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#include <String.h>
#include "SpawningUploadClient.h"
#include <errno.h>
#include <signal.h>
#include <stdlib.h>
#include <unistd.h>
#include <image.h>
#include <String.h>
SpawningUploadClient::SpawningUploadClient()
: FileUploadClient()
, fCommand()
, fCommandPid(-1)
, fPty(-1)
:
FileUploadClient(),
fCommand(),
fCommandPid(-1),
fPty(-1)
{
}
@@ -22,18 +31,21 @@ SpawningUploadClient::~SpawningUploadClient()
close(fPty);
kill(fCommandPid, SIGTERM);
kill(fCommandPid, SIGKILL);
status_t ret;
wait_for_thread(fCommandPid, &ret);
}
bool
SpawningUploadClient::Connect(const string& server, const string& login, const string& passwd)
SpawningUploadClient::Connect(const string& server, const string& login,
const string& passwd)
{
bool rc = false;
// fCommand += " ";
// fCommand += server;
rc = SpawnCommand();
return rc;
}
@@ -64,6 +76,7 @@ printf("spawning: '%s'\n", shellcmd.String());
if (fCommandPid < 0)
return false;
resume_thread(fCommandPid);
return true;
}
@@ -88,11 +101,13 @@ SpawningUploadClient::ReadReply(BString *to)
{
char buff[1024];
ssize_t len;
to->Truncate(0);
len = read(OutputPipe(), buff, 1024);
if (len < 0)
return errno;
to->Append(buff, len);
return len;
}
@@ -120,11 +135,9 @@ SpawningUploadClient::getpty(char *pty, char *tty)
sprintf(tty, "/dev/tt/%c%c", major[i], minor[j]);
fd = open(pty, O_RDWR|O_NOCTTY);
if (fd >= 0)
{
return fd;
}
}
}
return fd;
}
@@ -136,40 +149,37 @@ SpawningUploadClient::getpty(char *pty, char *tty)
bool
SpawningUploadClient::ChangeDir(const string& dir)
{
bool rc = false;
return rc;
return false;
}
bool
SpawningUploadClient::ListDirContents(string& listing)
{
bool rc = false;
return rc;
return false;
}
bool
SpawningUploadClient::PrintWorkingDir(string& dir)
{
bool rc = false;
return rc;
return false;
}
bool
SpawningUploadClient::PutFile(const string& local, const string& remote, ftp_mode mode)
SpawningUploadClient::PutFile(const string& local, const string& remote,
ftp_mode mode)
{
bool rc = false;
return rc;
return false;
}
bool
SpawningUploadClient::GetFile(const string& remote, const string& local, ftp_mode mode)
SpawningUploadClient::GetFile(const string& remote, const string& local,
ftp_mode mode)
{
bool rc = false;
return rc;
return false;
}
@@ -178,16 +188,14 @@ SpawningUploadClient::GetFile(const string& remote, const string& local, ftp_mod
bool
SpawningUploadClient::MoveFile(const string& oldPath, const string& newPath)
{
bool rc = false;
return rc;
return false;
}
bool
SpawningUploadClient::Chmod(const string& path, const string& mod)
{
bool rc = false;
return rc;
return false;
}
@@ -195,5 +203,3 @@ void
SpawningUploadClient::SetPassive(bool on)
{
}
+19 -6
View File
@@ -1,11 +1,18 @@
/*
* Copyright 1998-1999 Be, Inc. All Rights Reserved.
* Copyright 2003-2019 Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef SPAWNING_UPLOAD_CLIENT_H
#define SPAWNING_UPLOAD_CLIENT_H
#include "FileUploadClient.h"
#include <OS.h>
#include <stdio.h>
#include <string>
#include <string.h>
#include <OS.h>
#include <String.h>
class SpawningUploadClient : public FileUploadClient {
@@ -13,16 +20,20 @@ class SpawningUploadClient : public FileUploadClient {
SpawningUploadClient();
virtual ~SpawningUploadClient();
virtual bool Connect(const string& server, const string& login,
virtual bool Connect(const string& server,
const string& login,
const string& passwd);
virtual bool PutFile(const string& local, const string& remote,
virtual bool PutFile(const string& local,
const string& remote,
ftp_mode mode = binary_mode);
virtual bool GetFile(const string& remote, const string& local,
virtual bool GetFile(const string& remote,
const string& local,
ftp_mode mode = binary_mode);
virtual bool MoveFile(const string& oldPath, const string& newPath);
virtual bool MoveFile(const string& oldPath,
const string& newPath);
virtual bool ChangeDir(const string& dir);
virtual bool PrintWorkingDir(string& dir);
virtual bool ListDirContents(string& listing);
@@ -42,6 +53,8 @@ int OutputPipe() const { return fPty; };
private:
bool SpawnCommand();
private:
string fCommand;
pid_t fCommandPid;
int fPty;
+90 -57
View File
@@ -1,19 +1,19 @@
// Copyright (c) 1998-99, Be Incorporated, All Rights Reserved.
// SMS
// VideoConsumer.cpp
/*
* Copyright 1998-1999 Be, Inc. All Rights Reserved.
* Copyright 2003-2019 Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#include "FileUploadClient.h"
#include "FtpClient.h"
#include "SftpClient.h"
#include "VideoConsumer.h"
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <unistd.h>
#include <Application.h>
#include <BitmapStream.h>
#include <Buffer.h>
#include <BufferGroup.h>
#include <Catalog.h>
@@ -25,10 +25,15 @@
#include <TimeSource.h>
#include <View.h>
#include "FileUploadClient.h"
#include "FtpClient.h"
#include "SftpClient.h"
#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "VideoConsumer.cpp"
#define M1 ((double)1000000.0)
#define JITTER 20000
@@ -47,7 +52,8 @@ const media_raw_video_format vid_format = {29.97, 1, 0, 239,
VideoConsumer::VideoConsumer(const char* name, BView* view,
BStringView* statusLine,
BMediaAddOn* addon, const uint32 internalId)
: BMediaNode(name),
:
BMediaNode(name),
BMediaEventLooper(),
BBufferConsumer(B_MEDIA_RAW_VIDEO),
fStatusLine(statusLine),
@@ -75,7 +81,7 @@ VideoConsumer::VideoConsumer(const char* name, BView* view,
for (uint32 j = 0; j < 3; j++) {
fBitmap[j] = NULL;
fBufferMap[j] = 0;
fBufferMap[j] = NULL;
}
strcpy(fFileNameText, "");
@@ -99,7 +105,7 @@ VideoConsumer::~VideoConsumer()
if (fWindow->Lock()) {
puts(B_TRANSLATE("Closing the window"));
fWindow->Close();
fWindow = 0;
fWindow = NULL;
}
}
@@ -115,7 +121,6 @@ VideoConsumer::~VideoConsumer()
kill_thread(fFtpThread);
DeleteBuffers();
}
/********************************
@@ -192,13 +197,15 @@ VideoConsumer::RequestCompleted(const media_request_info& info)
switch (info.what) {
case media_request_info::B_SET_OUTPUT_BUFFERS_FOR:
if (info.status != B_OK)
ERROR("VideoConsumer::RequestCompleted: Not using our buffers!\n");
ERROR("VideoConsumer::RequestCompleted: "
"Not using our buffers!\n");
break;
default:
ERROR("VideoConsumer::RequestCompleted: Invalid argument\n");
break;
}
return B_OK;
}
@@ -208,7 +215,6 @@ VideoConsumer::HandleMessage(int32 message, const void* data, size_t size)
{
//FUNCTION("VideoConsumer::HandleMessage\n");
ftp_msg_info* info = (ftp_msg_info*)data;
status_t status = B_OK;
switch (message) {
case FTP_INFO:
@@ -224,8 +230,9 @@ VideoConsumer::HandleMessage(int32 message, const void* data, size_t size)
strcpy(fPasswordText, info->passwordText);
strcpy(fDirectoryText, info->directoryText);
// remove old user events
EventQueue()->FlushEvents(TimeSource()->Now(), BTimedEventQueue::B_ALWAYS,
true, BTimedEventQueue::B_USER_EVENT);
EventQueue()->FlushEvents(TimeSource()->Now(),
BTimedEventQueue::B_ALWAYS, true,
BTimedEventQueue::B_USER_EVENT);
if (fRate != B_INFINITE_TIMEOUT) {
// if rate is not "Never," push an event
// to restart captures 5 seconds from now
@@ -236,30 +243,31 @@ VideoConsumer::HandleMessage(int32 message, const void* data, size_t size)
break;
}
return status;
return B_OK;
}
void
VideoConsumer::BufferReceived(BBuffer* buffer)
{
LOOP("VideoConsumer::Buffer #%" B_PRId32 " received, start_time %" B_PRIdBIGTIME
"\n", buffer->ID(), buffer->Header()->start_time);
LOOP("VideoConsumer::Buffer #%" B_PRId32 " received, start_time %"
B_PRIdBIGTIME "\n", buffer->ID(), buffer->Header()->start_time);
if (RunState() == B_STOPPED) {
buffer->Recycle();
return;
}
media_timed_event event(buffer->Header()->start_time, BTimedEventQueue::B_HANDLE_BUFFER,
buffer, BTimedEventQueue::B_RECYCLE_BUFFER);
media_timed_event event(buffer->Header()->start_time,
BTimedEventQueue::B_HANDLE_BUFFER, buffer,
BTimedEventQueue::B_RECYCLE_BUFFER);
EventQueue()->AddEvent(event);
}
void
VideoConsumer::ProducerDataStatus(const media_destination& forWhom, int32 status,
bigtime_t atMediaTime)
VideoConsumer::ProducerDataStatus(const media_destination& forWhom,
int32 status, bigtime_t atMediaTime)
{
FUNCTION("VideoConsumer::ProducerDataStatus\n");
@@ -292,8 +300,8 @@ VideoConsumer::CreateBuffers(const media_format& withFormat)
}
// and attach the bitmaps to the buffer group
for (uint32 j = 0; j < 3; j++) {
fBitmap[j] = new BBitmap(BRect(0, 0, (xSize - 1), (ySize - 1)), colorspace,
false, true);
fBitmap[j] = new BBitmap(BRect(0, 0, (xSize - 1), (ySize - 1)),
colorspace, false, true);
if (fBitmap[j]->IsValid()) {
buffer_clone_info info;
if ((info.area = area_for(fBitmap[j]->Bits())) == B_ERROR)
@@ -304,11 +312,13 @@ VideoConsumer::CreateBuffers(const media_format& withFormat)
info.buffer = 0;
if ((status = fBuffers->AddBuffer(info)) != B_OK) {
ERROR("VideoConsumer::CreateBuffers - ERROR ADDING BUFFER TO GROUP\n");
ERROR("VideoConsumer::CreateBuffers - "
"ERROR ADDING BUFFER TO GROUP\n");
return status;
}
else
PROGRESS("VideoConsumer::CreateBuffers - SUCCESSFUL ADD BUFFER TO GROUP\n");
PROGRESS("VideoConsumer::CreateBuffers - "
"SUCCESSFUL ADD BUFFER TO GROUP\n");
} else {
ERROR("VideoConsumer::CreateBuffers - ERROR CREATING VIDEO RING "
"BUFFER: %08" B_PRIx32 "\n", status);
@@ -320,19 +330,22 @@ VideoConsumer::CreateBuffers(const media_format& withFormat)
for (int j = 0; j < 3; j++)
buffList[j] = NULL;
if ((status = fBuffers->GetBufferList(3, buffList)) == B_OK)
status = fBuffers->GetBufferList(3, buffList);
if (status == B_OK)
for (int j = 0; j < 3; j++)
if (buffList[j] != NULL) {
fBufferMap[j] = buffList[j];
PROGRESS(" j = %d buffer = %p\n", j, fBufferMap[j]);
} else {
ERROR("VideoConsumer::CreateBuffers ERROR MAPPING RING BUFFER\n");
ERROR("VideoConsumer::CreateBuffers "
"ERROR MAPPING RING BUFFER\n");
return B_ERROR;
}
else
ERROR("VideoConsumer::CreateBuffers ERROR IN GET BUFFER LIST\n");
fFtpBitmap = new BBitmap(BRect(0, 0, xSize - 1, ySize - 1), B_RGB32, false, false);
fFtpBitmap = new BBitmap(BRect(0, 0, xSize - 1, ySize - 1), B_RGB32, false,
false);
FUNCTION("VideoConsumer::CreateBuffers - EXIT\n");
return status;
@@ -354,13 +367,15 @@ VideoConsumer::DeleteBuffers()
fBitmap[j] = NULL;
}
}
FUNCTION("VideoConsumer::DeleteBuffers - EXIT\n");
}
status_t
VideoConsumer::Connected(const media_source& producer, const media_destination& where,
const media_format& withFormat, media_input* outInput)
VideoConsumer::Connected(const media_source& producer,
const media_destination& where, const media_format& withFormat,
media_input* outInput)
{
FUNCTION("VideoConsumer::Connected\n");
@@ -388,7 +403,8 @@ VideoConsumer::Connected(const media_source& producer, const media_destination&
void
VideoConsumer::Disconnected(const media_source& producer, const media_destination& where)
VideoConsumer::Disconnected(const media_source& producer,
const media_destination& where)
{
FUNCTION("VideoConsumer::Disconnected\n");
@@ -425,12 +441,14 @@ VideoConsumer::AcceptFormat(const media_destination& dest, media_format* format)
&& format->u.raw_video.display.format != B_RGB15
&& format->u.raw_video.display.format != B_GRAY8
&&
format->u.raw_video.display.format != media_raw_video_format::wildcard.display.format) {
format->u.raw_video.display.format
!= media_raw_video_format::wildcard.display.format) {
ERROR("AcceptFormat - not a format we know about!\n");
return B_MEDIA_BAD_FORMAT;
}
if (format->u.raw_video.display.format == media_raw_video_format::wildcard.display.format) {
if (format->u.raw_video.display.format
== media_raw_video_format::wildcard.display.format) {
format->u.raw_video.display.format = B_RGB16;
}
@@ -456,12 +474,13 @@ VideoConsumer::GetNextInput(int32* cookie, media_input* outInput)
sprintf(fIn.name, "Video Consumer");
*outInput = fIn;
(*cookie)++;
return B_OK;
} else {
}
ERROR("VideoConsumer::GetNextInput - - BAD INDEX\n");
return B_MEDIA_BAD_DESTINATION;
}
}
void
@@ -471,8 +490,8 @@ VideoConsumer::DisposeInputCookie(int32 /*cookie*/)
status_t
VideoConsumer::GetLatencyFor(const media_destination& forWhom, bigtime_t* outLatency,
media_node_id* out_timesource)
VideoConsumer::GetLatencyFor(const media_destination& forWhom,
bigtime_t* outLatency, media_node_id* out_timesource)
{
FUNCTION("VideoConsumer::GetLatencyFor\n");
@@ -486,8 +505,9 @@ VideoConsumer::GetLatencyFor(const media_destination& forWhom, bigtime_t* outLat
status_t
VideoConsumer::FormatChanged(const media_source& producer, const media_destination& consumer,
int32 fromChangeCount, const media_format& format)
VideoConsumer::FormatChanged(const media_source& producer,
const media_destination& consumer, int32 fromChangeCount,
const media_format& format)
{
FUNCTION("VideoConsumer::FormatChanged\n");
@@ -518,8 +538,9 @@ VideoConsumer::HandleEvent(const media_timed_event* event, bigtime_t lateness,
case BTimedEventQueue::B_STOP:
PROGRESS("VideoConsumer::HandleEvent - STOP\n");
EventQueue()->FlushEvents(event->event_time, BTimedEventQueue::B_ALWAYS,
true, BTimedEventQueue::B_HANDLE_BUFFER);
EventQueue()->FlushEvents(event->event_time,
BTimedEventQueue::B_ALWAYS, true,
BTimedEventQueue::B_HANDLE_BUFFER);
break;
case BTimedEventQueue::B_USER_EVENT:
@@ -555,26 +576,34 @@ VideoConsumer::HandleEvent(const media_timed_event* event, bigtime_t lateness,
}
if (fFtpComplete && fTimeToFtp) {
PROGRESS("VidConsumer::HandleEvent - SPAWNING FTP THREAD\n");
PROGRESS("VidConsumer::HandleEvent - "
"SPAWNING FTP THREAD\n");
fTimeToFtp = false;
fFtpComplete = false;
memcpy(fFtpBitmap->Bits(), buffer->Data(), fFtpBitmap->BitsLength());
fFtpThread = spawn_thread(FtpRun, "Video Window Ftp", B_NORMAL_PRIORITY, this);
memcpy(fFtpBitmap->Bits(), buffer->Data(),
fFtpBitmap->BitsLength());
fFtpThread = spawn_thread(FtpRun, "Video Window Ftp",
B_NORMAL_PRIORITY, this);
resume_thread(fFtpThread);
}
if ((RunMode() == B_OFFLINE)
|| ((TimeSource()->Now() > (buffer->Header()->start_time - JITTER))
&& (TimeSource()->Now() < (buffer->Header()->start_time + JITTER)))) {
|| ((TimeSource()->Now() >
(buffer->Header()->start_time - JITTER))
&& (TimeSource()->Now() <
(buffer->Header()->start_time + JITTER)))) {
if (!fOurBuffers)
// not our buffers, so we need to copy
memcpy(fBitmap[index]->Bits(), buffer->Data(), fBitmap[index]->BitsLength());
memcpy(fBitmap[index]->Bits(), buffer->Data(),
fBitmap[index]->BitsLength());
if (fWindow->Lock()) {
uint32 flags;
if ((fBitmap[index]->ColorSpace() == B_GRAY8) &&
!bitmaps_support_space(fBitmap[index]->ColorSpace(), &flags)) {
// handle mapping of GRAY8 until app server knows how
!bitmaps_support_space(fBitmap[index]->ColorSpace(),
&flags)) {
// handle mapping of GRAY8 until app server
// knows how
uint32* start = (uint32*)fBitmap[index]->Bits();
int32 size = fBitmap[index]->BitsLength();
uint32* end = start + size / 4;
@@ -620,7 +649,8 @@ VideoConsumer::FtpThread()
FUNCTION("VideoConsumer::FtpThread\n");
if (fUploadClient == 2) {
// 64 + 64 = 128 max
snprintf(fullPath, B_PATH_NAME_LENGTH, "%s/%s", fDirectoryText, fFileNameText);
snprintf(fullPath, B_PATH_NAME_LENGTH, "%s/%s", fDirectoryText,
fFileNameText);
LocalSave(fullPath, fFtpBitmap);
} else if (LocalSave(fFileNameText, fFtpBitmap) == B_OK)
FtpSave(fFileNameText);
@@ -666,14 +696,16 @@ VideoConsumer::LocalSave(char* filename, BBitmap* bitmap)
/* save a local copy of the image in the requested format */
output = new BFile();
if (output->SetTo(filename, B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE) == B_NO_ERROR) {
if (output->SetTo(filename, B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE)
== B_NO_ERROR) {
BBitmapStream input(bitmap);
status_t err = BTranslatorRoster::Default()->Translate(&input, NULL, NULL,
output, fImageFormat);
status_t err = BTranslatorRoster::Default()->Translate(&input, NULL,
NULL, output, fImageFormat);
if (err == B_OK) {
err = SetFileType(output, fTranslator, fImageFormat);
if (err != B_OK)
UpdateFtpStatus(B_TRANSLATE("Error setting type of output file"));
UpdateFtpStatus(
B_TRANSLATE("Error setting type of output file"));
}
else
UpdateFtpStatus(B_TRANSLATE("Error writing output file"));
@@ -681,12 +713,13 @@ VideoConsumer::LocalSave(char* filename, BBitmap* bitmap)
input.DetachBitmap(&bitmap);
output->Unset();
delete output;
return B_OK;
} else {
}
UpdateFtpStatus(B_TRANSLATE("Error creating output file"));
return B_ERROR;
}
}
status_t
+23 -13
View File
@@ -1,6 +1,8 @@
// Copyright (c) 1998-99, Be Incorporated, All Rights Reserved.
// SMS
/* VideoConsumer.h */
/*
* Copyright 1998-1999 Be, Inc. All Rights Reserved.
* Copyright 2003-2019 Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef VIDEO_CONSUMER_H
#define VIDEO_CONSUMER_H
@@ -10,7 +12,7 @@
#include <MediaEventLooper.h>
#include <MediaNode.h>
#include <TimedEventQueue.h>
#include <TranslationKit.h>
#include <TranslatorRoster.h>
#include <View.h>
#include <Window.h>
@@ -37,8 +39,9 @@ class BStringView;
class VideoConsumer : public BMediaEventLooper, public BBufferConsumer {
public:
VideoConsumer(const char* name, BView* view, BStringView* statusLine,
BMediaAddOn *addon, const uint32 internalId);
VideoConsumer(const char* name, BView* view,
BStringView* statusLine, BMediaAddOn *addon,
const uint32 internalId);
~VideoConsumer();
/* BMediaNode */
@@ -48,12 +51,14 @@ class VideoConsumer : public BMediaEventLooper, public BBufferConsumer {
protected:
virtual void Start(bigtime_t performanceTime);
virtual void Stop(bigtime_t performanceTime, bool immediate);
virtual void Seek(bigtime_t mediaTime, bigtime_t performanceTime);
virtual void Seek(bigtime_t mediaTime,
bigtime_t performanceTime);
virtual void TimeWarp(bigtime_t atRealTime,
bigtime_t toPerformanceTime);
virtual void NodeRegistered();
virtual status_t RequestCompleted(const media_request_info& info);
virtual status_t RequestCompleted(
const media_request_info& info);
virtual status_t HandleMessage(int32 message, const void* data,
size_t size);
@@ -70,7 +75,8 @@ class VideoConsumer : public BMediaEventLooper, public BBufferConsumer {
virtual status_t AcceptFormat(const media_destination& dest,
media_format* format);
virtual status_t GetNextInput(int32* cookie, media_input* outInput);
virtual status_t GetNextInput(int32* cookie,
media_input* outInput);
virtual void DisposeInputCookie(int32 cookie);
@@ -78,21 +84,25 @@ class VideoConsumer : public BMediaEventLooper, public BBufferConsumer {
virtual void BufferReceived(BBuffer* buffer);
private:
virtual void ProducerDataStatus(const media_destination &forWhom,
virtual void ProducerDataStatus(
const media_destination &forWhom,
int32 status, bigtime_t atMediaTime);
virtual status_t GetLatencyFor(const media_destination& forWhom,
bigtime_t* outLatency, media_node_id* outId);
bigtime_t* outLatency,
media_node_id* outId);
virtual status_t Connected(const media_source& producer,
const media_destination& where, const media_format& withFormat,
const media_destination& where,
const media_format& withFormat,
media_input* outInput);
virtual void Disconnected(const media_source& producer,
const media_destination& where);
virtual status_t FormatChanged(const media_source& producer,
const media_destination& consumer, int32 fromChangeCount,
const media_destination& consumer,
int32 fromChangeCount,
const media_format& format);
/* implementation */