Streaming: Remove any pointer BUrl argument

* There's no need to pass BUrl by pointer, this is
potentially dangerous and leaky without any advantage,
copying is definitely safer.
This commit is contained in:
Dario Casalinuovo 2016-06-24 13:54:25 +02:00
parent 43a03ceb4a
commit 0ba82236bd
23 changed files with 44 additions and 43 deletions

View File

@ -72,10 +72,10 @@ public:
// Additional constructors used to stream data from protocols
// supported by the Streamer API
BMediaFile(BUrl* url);
BMediaFile(BUrl* url, int32 flags);
BMediaFile(BUrl url);
BMediaFile(BUrl url, int32 flags);
// Read-Write streaming constructor
BMediaFile(BUrl* destination,
BMediaFile(BUrl destination,
const media_file_format* mfi,
int32 flags = 0);
@ -84,7 +84,7 @@ public:
status_t SetTo(const entry_ref* ref);
status_t SetTo(BDataIO* destination);
// The streaming equivalent of SetTo
status_t SetTo(BUrl* url);
status_t SetTo(BUrl url);
status_t InitCheck() const;

View File

@ -40,7 +40,7 @@ struct stream_info {
class MediaExtractor {
public:
MediaExtractor(BDataIO* source, int32 flags);
MediaExtractor(BUrl* url, int32 flags);
MediaExtractor(BUrl url, int32 flags);
~MediaExtractor();

View File

@ -22,7 +22,7 @@ class MediaWriter {
public:
MediaWriter(BDataIO* target,
const media_file_format& fileFormat);
MediaWriter(BUrl* url,
MediaWriter(BUrl url,
const media_file_format& fileFormat);
~MediaWriter();

View File

@ -61,7 +61,7 @@ public:
void DestroyEncoder(Encoder* encoder);
status_t CreateStreamer(Streamer** streamer,
BUrl* url, BDataIO** source);
BUrl url, BDataIO** source);
void DestroyStreamer(Streamer* streamer);
private:

View File

@ -18,7 +18,7 @@ public:
Streamer();
virtual ~Streamer();
virtual status_t Sniff(BUrl* url, BDataIO** source) = 0;
virtual status_t Sniff(BUrl url, BDataIO** source) = 0;
private:
virtual void _ReservedStreamer1();
virtual void _ReservedStreamer2();

View File

@ -72,7 +72,7 @@ private:
};
HTTPMediaIO::HTTPMediaIO(BUrl* url)
HTTPMediaIO::HTTPMediaIO(BUrl url)
:
BAdapterIO(
B_MEDIA_STREAMING | B_MEDIA_SEEK_BACKWARD,
@ -84,7 +84,7 @@ HTTPMediaIO::HTTPMediaIO(BUrl* url)
fListener = new FileListener(this);
fReq = BUrlProtocolRoster::MakeRequest(*url,
fReq = BUrlProtocolRoster::MakeRequest(url,
fListener, fContext);
fReq->Run();

View File

@ -17,7 +17,7 @@ class FileListener;
class HTTPMediaIO : public BAdapterIO {
public:
HTTPMediaIO(BUrl* url);
HTTPMediaIO(BUrl url);
virtual ~HTTPMediaIO();
status_t InitCheck() const;

View File

@ -20,7 +20,7 @@ HTTPStreamer::~HTTPStreamer()
status_t
HTTPStreamer::Sniff(BUrl* url, BDataIO** source)
HTTPStreamer::Sniff(BUrl url, BDataIO** source)
{
HTTPMediaIO* ret = new HTTPMediaIO(url);
if (ret->InitCheck() == B_OK) {

View File

@ -14,7 +14,7 @@ public:
HTTPStreamer();
virtual ~HTTPStreamer();
virtual status_t Sniff(BUrl* url, BDataIO** source);
virtual status_t Sniff(BUrl url, BDataIO** source);
};

View File

@ -10,7 +10,7 @@
#define LIVE555_VERBOSITY 1
RTSPMediaIO::RTSPMediaIO(BUrl* ourUrl)
RTSPMediaIO::RTSPMediaIO(BUrl ourUrl)
:
BAdapterIO(
B_MEDIA_STREAMING | B_MEDIA_MUTABLE_SIZE | B_MEDIA_SEEK_BACKWARD,
@ -25,7 +25,7 @@ RTSPMediaIO::RTSPMediaIO(BUrl* ourUrl)
fScheduler = BasicTaskScheduler::createNew();
fEnv = BasicUsageEnvironment::createNew(*fScheduler);
fClient = new HaikuRTSPClient(*fEnv, fUrl->UrlString(),
fClient = new HaikuRTSPClient(*fEnv, fUrl.UrlString(),
0, this);
if (fClient == NULL)
return;

View File

@ -18,7 +18,7 @@ class HaikuRTSPClient;
class RTSPMediaIO : public BAdapterIO
{
public:
RTSPMediaIO(BUrl* ourUrl);
RTSPMediaIO(BUrl ourUrl);
virtual ~RTSPMediaIO();
status_t InitCheck() const;
@ -34,7 +34,7 @@ public:
private:
static int32 _LoopThread(void* data);
BUrl* fUrl;
BUrl fUrl;
HaikuRTSPClient* fClient;
UsageEnvironment* fEnv;

View File

@ -15,7 +15,7 @@ RTSPStreamer::~RTSPStreamer()
status_t
RTSPStreamer::Sniff(BUrl* url, BDataIO** source)
RTSPStreamer::Sniff(BUrl url, BDataIO** source)
{
RTSPMediaIO* ret = new RTSPMediaIO(url);
if (ret->InitCheck() == B_OK) {

View File

@ -9,7 +9,7 @@ public:
RTSPStreamer();
virtual ~RTSPStreamer();
virtual status_t Sniff(BUrl* url, BDataIO** source);
virtual status_t Sniff(BUrl url, BDataIO** source);
};

View File

@ -637,7 +637,7 @@ Playlist::_ExtraMediaExists(Playlist* playlist, const entry_ref& ref)
/*static*/ bool
Playlist::_ExtraMediaExists(Playlist* playlist, BUrl* url)
Playlist::_ExtraMediaExists(Playlist* playlist, BUrl url)
{
for (int32 i = 0; i < playlist->CountItems(); i++) {
UrlPlaylistItem* compare

View File

@ -128,7 +128,7 @@ private:
static bool _ExtraMediaExists(Playlist* playlist,
const entry_ref& ref);
static bool _ExtraMediaExists(Playlist* playlist,
BUrl* url);
BUrl url);
static bool _IsImageFile(const BString& mimeString);
static bool _IsMediaFile(const BString& mimeString);
static bool _IsTextPlaylist(const BString& mimeString);

View File

@ -11,7 +11,7 @@
#include "MediaFileTrackSupplier.h"
UrlPlaylistItem::UrlPlaylistItem(BUrl* url)
UrlPlaylistItem::UrlPlaylistItem(BUrl url)
:
fUrl(url)
{
@ -21,7 +21,7 @@ UrlPlaylistItem::UrlPlaylistItem(BUrl* url)
UrlPlaylistItem::UrlPlaylistItem(const UrlPlaylistItem& item)
{
fUrl = new BUrl(item.Url()->UrlString());
fUrl = BUrl(item.Url());
}
@ -39,7 +39,7 @@ UrlPlaylistItem::~UrlPlaylistItem()
PlaylistItem*
UrlPlaylistItem::Clone() const
{
return new UrlPlaylistItem(new BUrl(fUrl->UrlString()));
return new UrlPlaylistItem(fUrl);
}
@ -102,7 +102,7 @@ UrlPlaylistItem::GetAttribute(const Attribute& attribute, int64& value) const
BString
UrlPlaylistItem::LocationURI() const
{
return fUrl->UrlString();
return fUrl.UrlString();
}
@ -147,7 +147,7 @@ UrlPlaylistItem::CreateTrackSupplier() const
}
BUrl*
BUrl
UrlPlaylistItem::Url() const
{
return fUrl;

View File

@ -12,7 +12,7 @@
class UrlPlaylistItem : public PlaylistItem {
public:
UrlPlaylistItem(BUrl* url);
UrlPlaylistItem(BUrl url);
UrlPlaylistItem(const UrlPlaylistItem& item);
UrlPlaylistItem(const BMessage* archive);
virtual ~UrlPlaylistItem();
@ -47,10 +47,10 @@ public:
virtual TrackSupplier* CreateTrackSupplier() const;
BUrl* Url() const;
BUrl Url() const;
private:
BUrl* fUrl;
BUrl fUrl;
};
#endif

View File

@ -93,7 +93,8 @@ for architectureObject in [ MultiArchSubDirSetup ] {
StreamerPlugin.cpp
WriterPlugin.cpp
:
be localestub shared [ TargetLibsupc++ ] [ TargetLibstdc++ ]
be localestub shared bnetapi
[ TargetLibsupc++ ] [ TargetLibstdc++ ]
;
}
}

View File

@ -64,7 +64,7 @@ MediaExtractor::MediaExtractor(BDataIO* source, int32 flags)
}
MediaExtractor::MediaExtractor(BUrl* url, int32 flags)
MediaExtractor::MediaExtractor(BUrl url, int32 flags)
:
fExtractorThread(-1),
fReader(NULL),

View File

@ -82,31 +82,31 @@ BMediaFile::BMediaFile(const media_file_format* mfi, int32 flags)
}
BMediaFile::BMediaFile(BUrl* url)
BMediaFile::BMediaFile(BUrl url)
{
CALLED();
fDeleteSource = true;
_Init();
_InitReader(NULL, url);
_InitReader(NULL, &url);
}
BMediaFile::BMediaFile(BUrl* url, int32 flags)
BMediaFile::BMediaFile(BUrl url, int32 flags)
{
CALLED();
fDeleteSource = true;
_Init();
_InitReader(NULL, url, flags);
_InitReader(NULL, &url, flags);
}
BMediaFile::BMediaFile(BUrl* destination, const media_file_format* mfi,
BMediaFile::BMediaFile(BUrl destination, const media_file_format* mfi,
int32 flags)
{
CALLED();
fDeleteSource = true;
_Init();
_InitWriter(NULL, destination, mfi, flags);
_InitWriter(NULL, &destination, mfi, flags);
// TODO: Implement streaming server support, it's
// a pretty complex thing compared to client mode
// and will require to expand the current BMediaFile
@ -488,7 +488,7 @@ BMediaFile::_InitReader(BDataIO* source, BUrl* url, int32 flags)
}
fExtractor = new(std::nothrow) MediaExtractor(source, flags);
} else
fExtractor = new(std::nothrow) MediaExtractor(url, flags);
fExtractor = new(std::nothrow) MediaExtractor(*url, flags);
if (fExtractor == NULL)
fErr = B_NO_MEMORY;
@ -532,7 +532,7 @@ BMediaFile::_InitWriter(BDataIO* target, BUrl* url,
if (target != NULL)
fWriter = new(std::nothrow) MediaWriter(target, fMFI);
else
fWriter = new(std::nothrow) MediaWriter(url, fMFI);
fWriter = new(std::nothrow) MediaWriter(*url, fMFI);
if (fWriter == NULL)
fErr = B_NO_MEMORY;

View File

@ -58,7 +58,7 @@ MediaWriter::MediaWriter(BDataIO* target, const media_file_format& fileFormat)
}
MediaWriter::MediaWriter(BUrl* url, const media_file_format& fileFormat)
MediaWriter::MediaWriter(BUrl url, const media_file_format& fileFormat)
:
fTarget(NULL),
fWriter(NULL),

View File

@ -595,7 +595,7 @@ PluginManager::DestroyEncoder(Encoder* encoder)
status_t
PluginManager::CreateStreamer(Streamer** streamer, BUrl* url, BDataIO** source)
PluginManager::CreateStreamer(Streamer** streamer, BUrl url, BDataIO** source)
{
TRACE("PluginManager::CreateStreamer enter\n");

View File

@ -19,8 +19,8 @@ int main(int argc, char *argv[])
printf("Instantiating the BMediaFile\n");
BUrl* url = new BUrl(argv[1]);
if (!url->IsValid()) {
BUrl url = BUrl(argv[1]);
if (!url.IsValid()) {
printf("Invalid URL\n");
return 0;
}