Fix various misc build issues in Windows

This is part of the effort to get edash_packager builds on Windows.

Change-Id: I1339f8f41a30ad3d5808ab19276d46ee902065e2
This commit is contained in:
KongQun Yang 2015-03-20 19:18:38 -07:00
parent d3c3a5573b
commit 7cac9da421
9 changed files with 81 additions and 12 deletions

View File

@ -4,6 +4,8 @@
#include "packager/media/base/bit_reader.h"
#include <algorithm>
namespace edash_packager {
namespace media {

View File

@ -22,9 +22,19 @@
'local_file.h',
'threaded_io_file.cc',
'threaded_io_file.h',
'udp_file.cc',
'udp_file.h',
],
'conditions': [
['OS == "win"', {
'sources': [
'udp_file_win.cc',
],
}, {
'sources': [
'udp_file_posix.cc',
],
}],
],
'dependencies': [
'../../base/base.gyp:base',
'../../third_party/gflags/gflags.gyp:gflags',

View File

@ -0,0 +1,51 @@
// Copyright 2015 Google Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
#include "packager/media/file/udp_file.h"
#include "packager/base/logging.h"
namespace edash_packager {
namespace media {
UdpFile::UdpFile(const char* file_name) : File(file_name), socket_(0) {
}
UdpFile::~UdpFile() {}
bool UdpFile::Close() {
NOTIMPLEMENTED();
delete this;
return false;
}
int64_t UdpFile::Read(void* buffer, uint64_t length) {
NOTIMPLEMENTED();
return -1;
}
int64_t UdpFile::Write(const void* buffer, uint64_t length) {
NOTIMPLEMENTED();
return -1;
}
int64_t UdpFile::Size() {
NOTIMPLEMENTED();
return -1;
}
bool UdpFile::Flush() {
NOTIMPLEMENTED();
return false;
}
bool UdpFile::Open() {
NOTIMPLEMENTED();
return false;
}
} // namespace media
} // namespace edash_packager

View File

@ -49,7 +49,7 @@ bool AdtsHeader::Parse(const uint8_t* adts_frame, size_t adts_frame_size) {
// Skip MPEG version and layer.
RCHECK(frame.SkipBits(3));
// Get "protection absent" flag.
bool protection_absent;
uint8_t protection_absent;
RCHECK(frame.ReadBits(1, &protection_absent));
// Get profile.
RCHECK(frame.ReadBits(2, &profile_));

View File

@ -145,9 +145,8 @@ TEST_F(Mp2tMediaParserTest, TimestampWrapAround) {
ParseMpeg2TsFile("bear-1280x720_ptswraparound.ts", 512);
parser_->Flush();
EXPECT_EQ(video_frame_count_, 82);
EXPECT_GE(video_min_dts_, (95443 - 1) * kMpeg2Timescale);
EXPECT_LE(video_max_dts_,
static_cast<int64_t>((95443 + 4)) * kMpeg2Timescale);
EXPECT_GE(video_min_dts_, static_cast<int64_t>(95443 - 1) * kMpeg2Timescale);
EXPECT_LE(video_max_dts_, static_cast<int64_t>(95443 + 4) * kMpeg2Timescale);
}
} // namespace mp2t

View File

@ -248,7 +248,7 @@ void MP4Muxer::FireOnMediaStartEvent() {
stream_info_vec,
timescale,
event::MuxerListener::kContainerMp4,
encryption_key_source());
encryption_key_source() != NULL);
}
void MP4Muxer::FireOnMediaEndEvent() {

View File

@ -336,7 +336,7 @@ Status Segmenter::FinalizeFragment(Fragmenter* fragmenter) {
// Fill in data offsets. Data offset base is moof size + mdat box size.
// (mdat is still empty, mdat size is the same as mdat box size).
uint64_t base = moof_->ComputeSize() + mdat.ComputeSize();
for (uint i = 0; i < moof_->tracks.size(); ++i) {
for (size_t i = 0; i < moof_->tracks.size(); ++i) {
TrackFragment& traf = moof_->tracks[i];
Fragmenter* fragmenter = fragmenters_[i];
if (fragmenter->aux_data()->Size() > 0) {
@ -356,7 +356,7 @@ Status Segmenter::FinalizeFragment(Fragmenter* fragmenter) {
// Write the fragment to buffer.
moof_->Write(fragment_buffer_.get());
for (uint i = 0; i < moof_->tracks.size(); ++i) {
for (size_t i = 0; i < moof_->tracks.size(); ++i) {
Fragmenter* fragmenter = fragmenters_[i];
mdat.data_size =
fragmenter->aux_data()->Size() + fragmenter->data()->Size();

View File

@ -7,9 +7,12 @@
#include "packager/media/formats/mp4/single_segment_segmenter.h"
#include <inttypes.h>
#include <openssl/err.h>
#include <openssl/rand.h>
#include "packager/base/file_util.h"
#include "packager/base/strings/stringprintf.h"
#include "packager/base/threading/platform_thread.h"
#include "packager/base/time/time.h"
#include "packager/media/base/buffer_writer.h"
#include "packager/media/base/media_stream.h"
@ -24,10 +27,14 @@ namespace mp4 {
namespace {
// Create a temp file name using process/thread id and current time.
std::string TempFileName() {
int32_t tid = static_cast<int32_t>(pthread_self());
int32_t pid = static_cast<int32_t>(getpid());
int64_t now = base::Time::Now().ToInternalValue();
return base::StringPrintf("packager-tempfile-%x-%d-%" PRIx64, tid, pid, now);
int32_t tid = static_cast<int32_t>(base::PlatformThread::CurrentId());
int64_t rand = 0;
if (RAND_bytes(reinterpret_cast<uint8_t*>(&rand), sizeof(rand)) != 1) {
LOG(WARNING) << "RAND_bytes failed with error: "
<< ERR_error_string(ERR_get_error(), NULL);
rand = base::Time::Now().ToInternalValue();
}
return base::StringPrintf("packager-tempfile-%x-%" PRIx64, tid, rand);
}
} // namespace