[haiku-commits] haiku: hrev50371 - src/kits/media src/apps/mediaplayer/playlist src/add-ons/media/plugins/rtsp_streamer src/add-ons/media/plugins/http_streamer headers/private/media

  • From: b.vitruvio@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Fri, 24 Jun 2016 19:02:18 +0200 (CEST)

hrev50371 adds 1 changeset to branch 'master'
old head: 43a03ceb4a869a48cc414d80d6ccc870e54be4bc
new head: 0ba82236bdd42192c263fcda6e1ba8475d0d88ac
overview: 
http://cgit.haiku-os.org/haiku/log/?qt=range&q=0ba82236bdd4+%5E43a03ceb4a86

----------------------------------------------------------------------------

0ba82236bdd4: 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.

                                [ Dario Casalinuovo <b.vitruvio@xxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev50371
Commit:      0ba82236bdd42192c263fcda6e1ba8475d0d88ac
URL:         http://cgit.haiku-os.org/haiku/commit/?id=0ba82236bdd4
Author:      Dario Casalinuovo <b.vitruvio@xxxxxxxxx>
Date:        Fri Jun 24 11:54:25 2016 UTC

----------------------------------------------------------------------------

23 files changed, 44 insertions(+), 43 deletions(-)
headers/os/media/MediaFile.h                         |  8 ++++----
headers/private/media/MediaExtractor.h               |  2 +-
headers/private/media/MediaWriter.h                  |  2 +-
headers/private/media/PluginManager.h                |  2 +-
headers/private/media/StreamerPlugin.h               |  2 +-
.../media/plugins/http_streamer/HTTPMediaIO.cpp      |  4 ++--
.../media/plugins/http_streamer/HTTPMediaIO.h        |  2 +-
.../plugins/http_streamer/HTTPStreamerPlugin.cpp     |  2 +-
.../media/plugins/http_streamer/HTTPStreamerPlugin.h |  2 +-
.../media/plugins/rtsp_streamer/RTSPMediaIO.cpp      |  4 ++--
.../media/plugins/rtsp_streamer/RTSPMediaIO.h        |  4 ++--
.../plugins/rtsp_streamer/RTSPStreamerPlugin.cpp     |  2 +-
.../media/plugins/rtsp_streamer/RTSPStreamerPlugin.h |  2 +-
src/apps/mediaplayer/playlist/Playlist.cpp           |  2 +-
src/apps/mediaplayer/playlist/Playlist.h             |  2 +-
src/apps/mediaplayer/playlist/UrlPlaylistItem.cpp    | 10 +++++-----
src/apps/mediaplayer/playlist/UrlPlaylistItem.h      |  6 +++---
src/kits/media/Jamfile                               |  3 ++-
src/kits/media/MediaExtractor.cpp                    |  2 +-
src/kits/media/MediaFile.cpp                         | 16 ++++++++--------
src/kits/media/MediaWriter.cpp                       |  2 +-
src/kits/media/PluginManager.cpp                     |  2 +-
src/tests/kits/media/streamer_sniff_test/main.cpp    |  4 ++--

----------------------------------------------------------------------------

diff --git a/headers/os/media/MediaFile.h b/headers/os/media/MediaFile.h
index 0a48f80..1b43365 100644
--- a/headers/os/media/MediaFile.h
+++ b/headers/os/media/MediaFile.h
@@ -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;
 
diff --git a/headers/private/media/MediaExtractor.h 
b/headers/private/media/MediaExtractor.h
index 91f65e3..ede1973 100644
--- a/headers/private/media/MediaExtractor.h
+++ b/headers/private/media/MediaExtractor.h
@@ -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();
 
diff --git a/headers/private/media/MediaWriter.h 
b/headers/private/media/MediaWriter.h
index df88014..ef3ae83 100644
--- a/headers/private/media/MediaWriter.h
+++ b/headers/private/media/MediaWriter.h
@@ -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();
 
diff --git a/headers/private/media/PluginManager.h 
b/headers/private/media/PluginManager.h
index 6f08a3f..7b863b7 100644
--- a/headers/private/media/PluginManager.h
+++ b/headers/private/media/PluginManager.h
@@ -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:
diff --git a/headers/private/media/StreamerPlugin.h 
b/headers/private/media/StreamerPlugin.h
index 907134e..ed3a5ac 100644
--- a/headers/private/media/StreamerPlugin.h
+++ b/headers/private/media/StreamerPlugin.h
@@ -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();
diff --git a/src/add-ons/media/plugins/http_streamer/HTTPMediaIO.cpp 
b/src/add-ons/media/plugins/http_streamer/HTTPMediaIO.cpp
index 81012de..079ab70 100644
--- a/src/add-ons/media/plugins/http_streamer/HTTPMediaIO.cpp
+++ b/src/add-ons/media/plugins/http_streamer/HTTPMediaIO.cpp
@@ -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();
diff --git a/src/add-ons/media/plugins/http_streamer/HTTPMediaIO.h 
b/src/add-ons/media/plugins/http_streamer/HTTPMediaIO.h
index e68ff1c..cc4634e 100644
--- a/src/add-ons/media/plugins/http_streamer/HTTPMediaIO.h
+++ b/src/add-ons/media/plugins/http_streamer/HTTPMediaIO.h
@@ -17,7 +17,7 @@ class FileListener;
 
 class HTTPMediaIO : public BAdapterIO {
 public:
-                                                                               
HTTPMediaIO(BUrl* url);
+                                                                               
HTTPMediaIO(BUrl url);
        virtual                                                         
~HTTPMediaIO();
 
                        status_t                                        
InitCheck() const;
diff --git a/src/add-ons/media/plugins/http_streamer/HTTPStreamerPlugin.cpp 
b/src/add-ons/media/plugins/http_streamer/HTTPStreamerPlugin.cpp
index f9ba530..dee0c1c 100644
--- a/src/add-ons/media/plugins/http_streamer/HTTPStreamerPlugin.cpp
+++ b/src/add-ons/media/plugins/http_streamer/HTTPStreamerPlugin.cpp
@@ -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) {
diff --git a/src/add-ons/media/plugins/http_streamer/HTTPStreamerPlugin.h 
b/src/add-ons/media/plugins/http_streamer/HTTPStreamerPlugin.h
index bb879c6..646bd91 100644
--- a/src/add-ons/media/plugins/http_streamer/HTTPStreamerPlugin.h
+++ b/src/add-ons/media/plugins/http_streamer/HTTPStreamerPlugin.h
@@ -14,7 +14,7 @@ public:
                                                                HTTPStreamer();
        virtual                                         ~HTTPStreamer();
 
-       virtual status_t                        Sniff(BUrl* url, BDataIO** 
source);
+       virtual status_t                        Sniff(BUrl url, BDataIO** 
source);
 };
 
 
diff --git a/src/add-ons/media/plugins/rtsp_streamer/RTSPMediaIO.cpp 
b/src/add-ons/media/plugins/rtsp_streamer/RTSPMediaIO.cpp
index 896f9bb..a1edd99 100644
--- a/src/add-ons/media/plugins/rtsp_streamer/RTSPMediaIO.cpp
+++ b/src/add-ons/media/plugins/rtsp_streamer/RTSPMediaIO.cpp
@@ -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;
diff --git a/src/add-ons/media/plugins/rtsp_streamer/RTSPMediaIO.h 
b/src/add-ons/media/plugins/rtsp_streamer/RTSPMediaIO.h
index d439023..8e234cc 100644
--- a/src/add-ons/media/plugins/rtsp_streamer/RTSPMediaIO.h
+++ b/src/add-ons/media/plugins/rtsp_streamer/RTSPMediaIO.h
@@ -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;
diff --git a/src/add-ons/media/plugins/rtsp_streamer/RTSPStreamerPlugin.cpp 
b/src/add-ons/media/plugins/rtsp_streamer/RTSPStreamerPlugin.cpp
index 001d804..5eeee54 100644
--- a/src/add-ons/media/plugins/rtsp_streamer/RTSPStreamerPlugin.cpp
+++ b/src/add-ons/media/plugins/rtsp_streamer/RTSPStreamerPlugin.cpp
@@ -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) {
diff --git a/src/add-ons/media/plugins/rtsp_streamer/RTSPStreamerPlugin.h 
b/src/add-ons/media/plugins/rtsp_streamer/RTSPStreamerPlugin.h
index 5ec8b01..a2d12c4 100644
--- a/src/add-ons/media/plugins/rtsp_streamer/RTSPStreamerPlugin.h
+++ b/src/add-ons/media/plugins/rtsp_streamer/RTSPStreamerPlugin.h
@@ -9,7 +9,7 @@ public:
                                                                RTSPStreamer();
        virtual                                         ~RTSPStreamer();
 
-       virtual status_t                        Sniff(BUrl* url, BDataIO** 
source);
+       virtual status_t                        Sniff(BUrl url, BDataIO** 
source);
 };
 
 
diff --git a/src/apps/mediaplayer/playlist/Playlist.cpp 
b/src/apps/mediaplayer/playlist/Playlist.cpp
index e43cba7..a4dd78d 100644
--- a/src/apps/mediaplayer/playlist/Playlist.cpp
+++ b/src/apps/mediaplayer/playlist/Playlist.cpp
@@ -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
diff --git a/src/apps/mediaplayer/playlist/Playlist.h 
b/src/apps/mediaplayer/playlist/Playlist.h
index 94980c5..a048d78 100644
--- a/src/apps/mediaplayer/playlist/Playlist.h
+++ b/src/apps/mediaplayer/playlist/Playlist.h
@@ -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);
diff --git a/src/apps/mediaplayer/playlist/UrlPlaylistItem.cpp 
b/src/apps/mediaplayer/playlist/UrlPlaylistItem.cpp
index 44f4232..a811fa9 100644
--- a/src/apps/mediaplayer/playlist/UrlPlaylistItem.cpp
+++ b/src/apps/mediaplayer/playlist/UrlPlaylistItem.cpp
@@ -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;
diff --git a/src/apps/mediaplayer/playlist/UrlPlaylistItem.h 
b/src/apps/mediaplayer/playlist/UrlPlaylistItem.h
index 93c3511..cf911f0 100644
--- a/src/apps/mediaplayer/playlist/UrlPlaylistItem.h
+++ b/src/apps/mediaplayer/playlist/UrlPlaylistItem.h
@@ -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
diff --git a/src/kits/media/Jamfile b/src/kits/media/Jamfile
index eeefaff..a23c542 100644
--- a/src/kits/media/Jamfile
+++ b/src/kits/media/Jamfile
@@ -93,7 +93,8 @@ for architectureObject in [ MultiArchSubDirSetup ] {
                        StreamerPlugin.cpp
                        WriterPlugin.cpp
                        :
-                       be localestub shared [ TargetLibsupc++ ] [ 
TargetLibstdc++ ]
+                       be localestub shared bnetapi
+                       [ TargetLibsupc++ ] [ TargetLibstdc++ ]
                        ;
        }
 }
diff --git a/src/kits/media/MediaExtractor.cpp 
b/src/kits/media/MediaExtractor.cpp
index 2847782..9be372b 100644
--- a/src/kits/media/MediaExtractor.cpp
+++ b/src/kits/media/MediaExtractor.cpp
@@ -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),
diff --git a/src/kits/media/MediaFile.cpp b/src/kits/media/MediaFile.cpp
index f93d27b..4629e9e 100644
--- a/src/kits/media/MediaFile.cpp
+++ b/src/kits/media/MediaFile.cpp
@@ -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;
diff --git a/src/kits/media/MediaWriter.cpp b/src/kits/media/MediaWriter.cpp
index b9e063e..dd9847c 100644
--- a/src/kits/media/MediaWriter.cpp
+++ b/src/kits/media/MediaWriter.cpp
@@ -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),
diff --git a/src/kits/media/PluginManager.cpp b/src/kits/media/PluginManager.cpp
index 8085566..c26fa3a 100644
--- a/src/kits/media/PluginManager.cpp
+++ b/src/kits/media/PluginManager.cpp
@@ -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");
 
diff --git a/src/tests/kits/media/streamer_sniff_test/main.cpp 
b/src/tests/kits/media/streamer_sniff_test/main.cpp
index 61b17ca..2a9e2b4 100644
--- a/src/tests/kits/media/streamer_sniff_test/main.cpp
+++ b/src/tests/kits/media/streamer_sniff_test/main.cpp
@@ -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;
        }


Other related posts: