summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjhurst <jhurst@cinecert.com>2006-09-23 23:47:17 +0000
committerjhurst <>2006-09-23 23:47:17 +0000
commit72e5392ca11c06a1ac0732c71f86df0d9a712ce3 (patch)
tree25c9f223d62700409fbe883865dc5a54677726a0 /src
parent1cd511e77b968ba068c59f4771cb67810e4ba4c4 (diff)
1.1.9 release a
Diffstat (limited to 'src')
-rwxr-xr-xsrc/AS_DCP.h4
-rwxr-xr-xsrc/JP2K_Codestream_Parser.cpp6
-rwxr-xr-xsrc/KLV.h2
-rw-r--r--src/KM_fileio.cpp5
-rwxr-xr-xsrc/KM_fileio.h2
-rwxr-xr-xsrc/KM_memio.h22
-rwxr-xr-xsrc/KM_prng.cpp33
-rwxr-xr-xsrc/KM_util.h138
-rwxr-xr-xsrc/MPEG2_Parser.cpp1
-rwxr-xr-xsrc/MXFTypes.h3
-rwxr-xr-xsrc/PCMParserList.h5
-rwxr-xr-xsrc/h__Writer.cpp6
-rwxr-xr-xsrc/kmfilegen.cpp20
-rwxr-xr-xsrc/wavesplit.cpp2
14 files changed, 144 insertions, 105 deletions
diff --git a/src/AS_DCP.h b/src/AS_DCP.h
index deccbbb..5dafdaa 100755
--- a/src/AS_DCP.h
+++ b/src/AS_DCP.h
@@ -143,7 +143,7 @@ namespace ASDCP {
// 1.0.1. If changes were also required in AS_DCP.h, the new version would be 1.1.1.
const ui32_t VERSION_MAJOR = 1;
const ui32_t VERSION_APIMINOR = 1;
- const ui32_t VERSION_IMPMINOR = 8;
+ const ui32_t VERSION_IMPMINOR = 9;
const char* Version();
// UUIDs are passed around as strings of UUIDlen bytes
@@ -201,8 +201,6 @@ namespace ASDCP {
ESS_JPEG_2000, // the file contains one or more JPEG 2000 codestreams
ESS_PCM_24b_48k, // the file contains one or more PCM audio pairs
ESS_PCM_24b_96k, // the file contains one or more PCM audio pairs
- ESS_UTF8_XML, // the file contains UTF-8 encoded XML data
- ESS_PNG // the file contains a Portable Network Graphics image
};
// Determine the type of essence contained in the given MXF file. RESULT_OK
diff --git a/src/JP2K_Codestream_Parser.cpp b/src/JP2K_Codestream_Parser.cpp
index 4211653..32a5316 100755
--- a/src/JP2K_Codestream_Parser.cpp
+++ b/src/JP2K_Codestream_Parser.cpp
@@ -90,6 +90,12 @@ public:
while ( p < end_p && ASDCP_SUCCESS(result) )
{
result = GetNextMarker(&p, NextMarker);
+
+ if ( ASDCP_FAILURE(result) )
+ {
+ result = RESULT_RAW_ESS;
+ break;
+ }
#if 0
fprintf(stderr, "%s Length: %u\n",
GetMarkerString(NextMarker.m_Type), NextMarker.m_DataSize);
diff --git a/src/KLV.h b/src/KLV.h
index 4271999..d685cf9 100755
--- a/src/KLV.h
+++ b/src/KLV.h
@@ -119,6 +119,8 @@ inline const char* ui64sz(ui64_t i, char* buf)
const char* EncodeString(char* str_buf, ui32_t buf_len) const;
};
+ const byte_t nil_UMID[SMPTE_UMID_LENGTH] = {0};
+ const UMID NilUMID(nil_UMID);
//
struct MDDEntry
diff --git a/src/KM_fileio.cpp b/src/KM_fileio.cpp
index a41669f..ef1c9dc 100644
--- a/src/KM_fileio.cpp
+++ b/src/KM_fileio.cpp
@@ -629,7 +629,10 @@ Kumu::ReadFileIntoString(const char* filename, std::string& outString, ui32_t ma
fsize = File.Size();
if ( fsize > (Kumu::fpos_t)max_size )
- return RESULT_ALLOC;
+ {
+ DefaultLogSink().Error("%s: exceeds available buffer size (%u)", filename, max_size);
+ return RESULT_ALLOC;
+ }
result = ReadBuf.Capacity((ui32_t)fsize);
}
diff --git a/src/KM_fileio.h b/src/KM_fileio.h
index b268ad7..96cdf00 100755
--- a/src/KM_fileio.h
+++ b/src/KM_fileio.h
@@ -114,7 +114,7 @@ namespace Kumu
fsize_t FileSize(const char* pathname);
// Reads an entire file into a string.
- Result_t ReadFileIntoString(const char* filename, std::string& outString, ui32_t max_size = 256 * Kilobyte);
+ Result_t ReadFileIntoString(const char* filename, std::string& outString, ui32_t max_size = 8 * Megabyte);
// Writes a string to a file, overwrites the existing file if present.
Result_t WriteStringIntoFile(const char* filename, const std::string& inString);
diff --git a/src/KM_memio.h b/src/KM_memio.h
index 8416b57..483bbde 100755
--- a/src/KM_memio.h
+++ b/src/KM_memio.h
@@ -33,7 +33,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define _KM_MEMIO_H_
#include <KM_platform.h>
-#include <string.h>
+#include <string>
namespace Kumu
{
@@ -207,6 +207,26 @@ namespace Kumu
}
};
+ //
+ inline bool
+ UnarchiveString(MemIOReader& Reader, std::string& str)
+ {
+ ui32_t str_length;
+ if ( ! Reader.ReadUi32BE(&str_length) ) return false;
+ str.assign((const char*)Reader.CurrentData(), str_length);
+ if ( ! Reader.SkipOffset(str_length) ) return false;
+ return true;
+ }
+
+ //
+ inline bool
+ ArchiveString(MemIOWriter& Writer, const std::string& str)
+ {
+ if ( ! Writer.WriteUi32BE(str.length()) ) return false;
+ if ( ! Writer.WriteRaw((const byte_t*)str.c_str(), str.length()) ) return false;
+ return true;
+ }
+
} // namespace Kumu
#endif // _KM_MEMIO_H_
diff --git a/src/KM_prng.cpp b/src/KM_prng.cpp
index 01d4b1d..094ee1b 100755
--- a/src/KM_prng.cpp
+++ b/src/KM_prng.cpp
@@ -41,31 +41,10 @@ using namespace Kumu;
#ifdef KM_WIN32
-
-// make up a byte by sampling the perf counter LSB
-static byte_t get_perf_byte(byte_t carry)
-{
- LARGE_INTEGER ticks;
- byte_t sha_buf[20];
- SHA_CTX SHA;
- SHA1_Init(&SHA);
- SHA1_Update(&SHA, &carry, sizeof(byte_t));
-
- for ( int i = 0; i < 128; i++ )
- {
- QueryPerformanceCounter(&ticks);
- SHA1_Update(&SHA, &ticks.LowPart, sizeof(ticks.LowPart));
- }
-
- SHA1_Final(sha_buf, &SHA);
- return sha_buf[0];
-}
-
+# include <wincrypt.h>
#else // KM_WIN32
-
-#include <KM_fileio.h>
+# include <KM_fileio.h>
const char* DEV_URANDOM = "/dev/urandom";
-
#endif // KM_WIN32
@@ -95,11 +74,9 @@ public:
AutoMutex Lock(m_Lock);
#ifdef KM_WIN32
- for ( ui32_t i = 0; i < RNG_KEY_SIZE; i++ )
- {
- byte_t carry = ( i == 0 ) ? 0xa3 : rng_key[i-1];
- rng_key[i] = get_perf_byte(carry);
- }
+ HCRYPTPROV hProvider = 0;
+ CryptAcquireContext(&hProvider, 0, 0, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT);
+ CryptGenRandom(hProvider, RNG_KEY_SIZE, rng_key);
#else // KM_WIN32
// on POSIX systems we simply read some seed from /dev/urandom
FileReader URandom;
diff --git a/src/KM_util.h b/src/KM_util.h
index 9d975b9..d210bb9 100755
--- a/src/KM_util.h
+++ b/src/KM_util.h
@@ -40,18 +40,29 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
namespace Kumu
{
+ // a class that represents the string form of a value
template <class T, int SIZE = 16>
class IntPrinter : public std::string
{
- protected:
+ KM_NO_COPY_CONSTRUCT(IntPrinter);
IntPrinter();
+
+ protected:
+ const char* m_format;
char m_strbuf[SIZE];
public:
- inline const char* c_str() { return m_strbuf; }
-
IntPrinter(const char* format, T value) {
- snprintf(m_strbuf, SIZE, format, value);
+ assert(format);
+ m_format = format;
+ snprintf(m_strbuf, SIZE, m_format, value);
+ }
+
+ inline operator const char*() { return m_strbuf; }
+ inline const char* c_str() { return m_strbuf; }
+ inline const char* set_value(T value) {
+ snprintf(m_strbuf, SIZE, m_format, value);
+ return m_strbuf;
}
};
@@ -152,6 +163,8 @@ namespace Kumu
//----------------------------------------------------------------
//
+ // an abstract base class that objects implement to serialize state
+ // to and from a binary stream.
class IArchive
{
public:
@@ -163,7 +176,9 @@ namespace Kumu
//
- // the base of all identifier classes
+ // the base of all identifier classes, Identifier is not usually used directly
+ // see UUID and SymmetricKey below for more detail.
+ //
template <ui32_t SIZE>
class Identifier : public IArchive
{
@@ -191,57 +206,51 @@ namespace Kumu
inline const byte_t* Value() const { return m_Value; }
inline ui32_t Size() const { return SIZE; }
- inline bool operator<(const Identifier& rhs) const
- {
- ui32_t test_size = xmin(rhs.Size(), SIZE);
- for ( ui32_t i = 0; i < test_size; i++ )
- {
- if ( m_Value[i] != rhs.m_Value[i] )
- return m_Value[i] < rhs.m_Value[i];
- }
-
- return false;
- }
-
- inline bool operator==(const Identifier& rhs) const
- {
- if ( rhs.Size() != SIZE ) return false;
- return ( memcmp(m_Value, rhs.m_Value, SIZE) == 0 );
- }
-
- inline bool operator!=(const Identifier& rhs) const
- {
- if ( rhs.Size() != SIZE ) return true;
- return ( memcmp(m_Value, rhs.m_Value, SIZE) != 0 );
- }
-
- inline bool DecodeHex(const char* str)
- {
- ui32_t char_count;
- m_HasValue = ( hex2bin(str, m_Value, SIZE, &char_count) == 0 );
- return m_HasValue;
- }
-
- inline const char* EncodeHex(char* buf, ui32_t buf_len) const
- {
- return bin2hex(m_Value, SIZE, buf, buf_len);
- }
+ inline bool operator<(const Identifier& rhs) const {
+ ui32_t test_size = xmin(rhs.Size(), SIZE);
+
+ for ( ui32_t i = 0; i < test_size; i++ )
+ {
+ if ( m_Value[i] != rhs.m_Value[i] )
+ return m_Value[i] < rhs.m_Value[i];
+ }
+
+ return false;
+ }
+
+ inline bool operator==(const Identifier& rhs) const {
+ if ( rhs.Size() != SIZE ) return false;
+ return ( memcmp(m_Value, rhs.m_Value, SIZE) == 0 );
+ }
+
+ inline bool operator!=(const Identifier& rhs) const {
+ if ( rhs.Size() != SIZE ) return true;
+ return ( memcmp(m_Value, rhs.m_Value, SIZE) != 0 );
+ }
+
+ inline bool DecodeHex(const char* str) {
+ ui32_t char_count;
+ m_HasValue = ( hex2bin(str, m_Value, SIZE, &char_count) == 0 );
+ return m_HasValue;
+ }
+
+ inline const char* EncodeHex(char* buf, ui32_t buf_len) const {
+ return bin2hex(m_Value, SIZE, buf, buf_len);
+ }
inline const char* EncodeString(char* str_buf, ui32_t buf_len) const {
return EncodeHex(str_buf, buf_len);
}
- inline bool DecodeBase64(const char* str)
- {
- ui32_t char_count;
- m_HasValue = ( base64decode(str, m_Value, SIZE, &char_count) == 0 );
- return m_HasValue;
- }
+ inline bool DecodeBase64(const char* str) {
+ ui32_t char_count;
+ m_HasValue = ( base64decode(str, m_Value, SIZE, &char_count) == 0 );
+ return m_HasValue;
+ }
- inline const char* EncodeBase64(char* buf, ui32_t buf_len) const
- {
- return base64encode(m_Value, SIZE, buf, buf_len);
- }
+ inline const char* EncodeBase64(char* buf, ui32_t buf_len) const {
+ return base64encode(m_Value, SIZE, buf, buf_len);
+ }
inline bool HasValue() const { return m_HasValue; }
@@ -326,19 +335,23 @@ namespace Kumu
// decode and set value from string formatted by EncodeString
bool DecodeString(const char* datestr);
- // add the given number of days or hours to the timestamp value. Values less than zero
- // will cause the value to decrease
+ // Add the given number of days or hours to the timestamp value.
+ // Values less than zero will cause the timestamp to decrease
void AddDays(i32_t);
void AddHours(i32_t);
- // Read and write the timestamp value as a byte string
+ // Read and write the timestamp value as a byte string having
+ // the following format:
+ // | 16 bits int, big-endian | 8 bits | 8 bits | 8 bits | 8 bits | 8 bits |
+ // | Year A.D | Month(1-12) | Day(1-31) | Hour(0-23) | Minute(0-59) | Second(0-59) |
+ //
virtual bool HasValue() const;
virtual bool Archive(MemIOWriter* Writer) const;
virtual bool Unarchive(MemIOReader* Reader);
};
//
- class ByteString
+ class ByteString : public IArchive
{
KM_NO_COPY_CONSTRUCT(ByteString);
@@ -377,6 +390,23 @@ namespace Kumu
// copy the given data into the ByteString, set Length value.
// Returns error if the ByteString is too small.
Result_t Set(const byte_t* buf, ui32_t buf_len);
+
+ inline virtual bool HasValue() const { return m_Length > 0; }
+
+ inline virtual bool Archive(MemIOWriter* Writer) const {
+ assert(Writer);
+ if ( ! Writer->WriteUi32BE(m_Length) ) return false;
+ if ( ! Writer->WriteRaw(m_Data, m_Length) ) return false;
+ return true;
+ }
+
+ inline virtual bool Unarchive(MemIOReader* Reader) {
+ assert(Reader);
+ if ( ! Reader->ReadUi32BE(&m_Length) ) return false;
+ if ( KM_FAILURE(Capacity(m_Length)) ) return false;
+ if ( ! Reader->ReadRaw(m_Data, m_Length) ) return false;
+ return true;
+ }
};
} // namespace Kumu
diff --git a/src/MPEG2_Parser.cpp b/src/MPEG2_Parser.cpp
index bba10b1..791a889 100755
--- a/src/MPEG2_Parser.cpp
+++ b/src/MPEG2_Parser.cpp
@@ -414,6 +414,7 @@ ASDCP::MPEG2::Parser::h__Parser::OpenRead(const char* filename)
if ( ASDCP_SUCCESS(result) )
{
+ m_ParamsDelegate.m_VDesc.ContainerDuration = m_FileReader.Size() / 65536; // a gross approximation
m_Parser.SetDelegate(&m_ParserDelegate);
m_FileReader.Seek(0);
}
diff --git a/src/MXFTypes.h b/src/MXFTypes.h
index 051832b..f2bef5b 100755
--- a/src/MXFTypes.h
+++ b/src/MXFTypes.h
@@ -385,7 +385,7 @@ namespace ASDCP
};
//
- class Raw : public Kumu::ByteString, public Kumu::IArchive
+ class Raw : public Kumu::ByteString
{
ASDCP_NO_COPY_CONSTRUCT(Raw);
@@ -395,7 +395,6 @@ namespace ASDCP
//
virtual bool Unarchive(Kumu::MemIOReader* Reader);
- inline virtual bool HasValue() const { return Length() > 0; }
virtual bool Archive(Kumu::MemIOWriter* Writer) const;
const char* EncodeString(char* str_buf, ui32_t buf_len) const;
};
diff --git a/src/PCMParserList.h b/src/PCMParserList.h
index e6bf20b..ae433f0 100755
--- a/src/PCMParserList.h
+++ b/src/PCMParserList.h
@@ -62,11 +62,12 @@ namespace ASDCP
//
class PCMParserList : public std::vector<ParserInstance*>
{
+ ASDCP_NO_COPY_CONSTRUCT(PCMParserList);
+
+ protected:
PCM::AudioDescriptor m_ADesc;
ui32_t m_ChannelCount;
- ASDCP_NO_COPY_CONSTRUCT(PCMParserList);
-
public:
PCMParserList();
virtual ~PCMParserList();
diff --git a/src/h__Writer.cpp b/src/h__Writer.cpp
index 297c741..1d1607f 100755
--- a/src/h__Writer.cpp
+++ b/src/h__Writer.cpp
@@ -201,8 +201,10 @@ ASDCP::h__Writer::WriteMXFHeader(const std::string& PackageLabel, const UL& Wrap
m_FilePackage->Name = PackageLabel.c_str();
m_FilePackage->PackageUID = PackageUMID;
ECD->LinkedPackageUID = PackageUMID;
- m_MPClip->SourcePackageID = PackageUMID;
- m_MPClip->SourceTrackID = 1;
+
+ // for now we do not allow setting this value, so all files will be 'original'
+ m_MPClip->SourcePackageID = NilUMID;
+ m_MPClip->SourceTrackID = 0;
m_HeaderPart.AddChildObject(m_FilePackage);
Storage->Packages.push_back(m_FilePackage->InstanceUID);
diff --git a/src/kmfilegen.cpp b/src/kmfilegen.cpp
index 38387a8..9ab1f00 100755
--- a/src/kmfilegen.cpp
+++ b/src/kmfilegen.cpp
@@ -299,7 +299,7 @@ CreateLargeFile(CommandOptions& Options)
FB.Capacity(Megabyte);
assert(FB.Capacity() == Megabyte);
- fprintf(stderr, "Writing %lu chunks:\n", Options.chunk_count);
+ fprintf(stderr, "Writing %u chunks:\n", Options.chunk_count);
s_Nonce = Options.chunk_count;
Result_t result = Writer.OpenWrite(Options.filename);
@@ -312,7 +312,7 @@ CreateLargeFile(CommandOptions& Options)
CTR.FillRandom(FB.Data() + CTR.WriteSize(), Megabyte - CTR.WriteSize());
result = Writer.Write(FB.RoData(), Megabyte, &write_count);
assert(write_count == Megabyte);
- fprintf(stderr, "\r%8lu ", ++write_total);
+ fprintf(stderr, "\r%8u ", ++write_total);
}
}
@@ -411,7 +411,7 @@ ReadValidateWriteLargeFile(CommandOptions& Options)
{
if ( read_count < Megabyte )
{
- fprintf(stderr, "Read() returned short buffer: %lu\n", read_count);
+ fprintf(stderr, "Read() returned short buffer: %u\n", read_count);
result = RESULT_FAIL;
}
@@ -421,7 +421,7 @@ ReadValidateWriteLargeFile(CommandOptions& Options)
{
result = Writer.Write(FB.RoData(), Megabyte, &write_count);
assert(write_count == Megabyte);
- fprintf(stderr, "\r%8lu ", ++write_total);
+ fprintf(stderr, "\r%8u ", ++write_total);
}
}
else if ( result == RESULT_ENDOFFILE )
@@ -461,7 +461,7 @@ ValidateLargeFile(CommandOptions& Options)
if ( read_count < Megabyte )
{
- fprintf(stderr, "Read() returned short buffer: %lu\n", read_count);
+ fprintf(stderr, "Read() returned short buffer: %u\n", read_count);
result = RESULT_FAIL;
}
else if ( KM_SUCCESS(result) )
@@ -469,7 +469,7 @@ ValidateLargeFile(CommandOptions& Options)
if ( KM_SUCCESS(result) )
{
- fprintf(stderr, "Validating %lu chunk%s in %s order:\n",
+ fprintf(stderr, "Validating %u chunk%s in %s order:\n",
check_total, (check_total == 1 ? "" : "s"), Options.order);
assert(read_list == 0);
read_list = (read_list_t*)malloc(check_total * sizeof(read_list_t));
@@ -510,7 +510,7 @@ ValidateLargeFile(CommandOptions& Options)
read_list_i < check_total && KM_SUCCESS(result);
read_list_i++ )
{
- fprintf(stderr, "\r%8lu [%8lu] ", read_list_i+1, read_list[read_list_i]);
+ fprintf(stderr, "\r%8u [%8u] ", read_list_i+1, read_list[read_list_i].nonce);
result = Reader.Seek(read_list[read_list_i].position);
if ( KM_SUCCESS(result) )
@@ -521,7 +521,7 @@ ValidateLargeFile(CommandOptions& Options)
else if ( read_count < Megabyte )
{
- fprintf(stderr, "Read() returned short buffer: %lu\n", read_count);
+ fprintf(stderr, "Read() returned short buffer: %u\n", read_count);
result = RESULT_FAIL;
}
else if ( KM_SUCCESS(result) )
@@ -530,7 +530,7 @@ ValidateLargeFile(CommandOptions& Options)
if ( nonce != read_list[read_list_i].nonce )
{
- fprintf(stderr, "Nonce mismatch: expecting %lu, got %lu\n",
+ fprintf(stderr, "Nonce mismatch: expecting %u, got %u\n",
nonce, read_list[read_list_i].nonce);
return RESULT_FAIL;
@@ -547,7 +547,7 @@ ValidateLargeFile(CommandOptions& Options)
result = RESULT_OK;
else
{
- fprintf(stderr, "Unexpected chunk count, got %lu, wanted %lu\n",
+ fprintf(stderr, "Unexpected chunk count, got %u, wanted %u\n",
read_list_i, check_total);
result = RESULT_FAIL;
}
diff --git a/src/wavesplit.cpp b/src/wavesplit.cpp
index cdfb98e..964e616 100755
--- a/src/wavesplit.cpp
+++ b/src/wavesplit.cpp
@@ -74,7 +74,7 @@ wavesplit is part of asdcplib.\n\
asdcplib may be copied only under the terms of the license found at\n\
the top of every file in the asdcplib distribution kit.\n\n\
Specify the -h (help) option for further information about %s\n\n",
- PACKAGE, ASDCP::Version(), PACKAGE, PACKAGE);
+ PACKAGE, ASDCP::Version(), PACKAGE);
}
//