Bug 1220882 - Use LazyLogModule in MP4Metadata. r=kinetik

Use the new LazyLogModule to instantiate a log for the rust
mp4parse test code instead of using indiscriminate printf()s.

Access results with NSPR_LOG_MODULES=MP4Metadata:5.
This commit is contained in:
Ralph Giles 2015-11-02 16:19:00 -08:00
Родитель 87aab4c5c3
Коммит 62347f7023
1 изменённых файлов: 8 добавлений и 8 удалений

Просмотреть файл

@ -7,6 +7,7 @@
#include "media/stagefright/MediaDefs.h" #include "media/stagefright/MediaDefs.h"
#include "media/stagefright/MediaSource.h" #include "media/stagefright/MediaSource.h"
#include "media/stagefright/MetaData.h" #include "media/stagefright/MetaData.h"
#include "mozilla/Logging.h"
#include "mozilla/Monitor.h" #include "mozilla/Monitor.h"
#include "mp4_demuxer/MoofParser.h" #include "mp4_demuxer/MoofParser.h"
#include "mp4_demuxer/MP4Metadata.h" #include "mp4_demuxer/MP4Metadata.h"
@ -113,26 +114,25 @@ MP4Metadata::~MP4Metadata()
// Helper to test the rust parser on a data source. // Helper to test the rust parser on a data source.
static bool try_rust(RefPtr<Stream> aSource) static bool try_rust(RefPtr<Stream> aSource)
{ {
static LazyLogModule sLog("MP4Metadata");
int64_t length; int64_t length;
if (!aSource->Length(&length)) { if (!aSource->Length(&length) || length <= 0) {
fprintf(stderr, "Couldn't get source length\n"); MOZ_LOG(sLog, LogLevel::Warning, ("Couldn't get source length"));
return false;
}
fprintf(stderr, "Source length %d bytes\n", (long long int)length);
if (length <= 0) {
return false; return false;
} }
MOZ_LOG(sLog, LogLevel::Debug,
("Source length %d bytes\n", (long long int)length));
size_t bytes_read = 0; size_t bytes_read = 0;
auto buffer = std::vector<uint8_t>(length); auto buffer = std::vector<uint8_t>(length);
bool rv = aSource->ReadAt(0, buffer.data(), length, &bytes_read); bool rv = aSource->ReadAt(0, buffer.data(), length, &bytes_read);
if (!rv || bytes_read != size_t(length)) { if (!rv || bytes_read != size_t(length)) {
fprintf(stderr, "Error copying mp4 data\n"); MOZ_LOG(sLog, LogLevel::Warning, ("Error copying mp4 data"));
return false; return false;
} }
auto context = mp4parse_new(); auto context = mp4parse_new();
int32_t tracks = mp4parse_read(context, buffer.data(), bytes_read); int32_t tracks = mp4parse_read(context, buffer.data(), bytes_read);
mp4parse_free(context); mp4parse_free(context);
fprintf(stderr, "rust parser found %d tracks\n", int(tracks)); MOZ_LOG(sLog, LogLevel::Info, ("rust parser found %d tracks", int(tracks)));
return true; return true;
} }
#endif #endif