Files
android/libwvdrmengine/cdm/profiler/include/entry_writer.h
Aaron Vaage a249c67504 OEMCrypto Profiler
This CL is a merge from the widevine repo of:
http://go/wvgerrit/16491 Circular Buffer
http://go/wvgerrit/16512 Circular Buffer Tests
http://go/wvgerrit/16493 Entry Writer
http://go/wvgerrit/16495 Profiled Scope
http://go/wvgerrit/16500 Stats Collection
http://go/wvgerrit/16543 Disallow Stats Copy or Assign
http://go/wvgerrit/16514 Moving OEM Function Enum
http://go/wvgerrit/16501 Defining Session Interface
http://go/wvgerrit/16502 Session Definitions
http://go/wvgerrit/16573 Remove code to num bytes table
http://go/wvgerrit/16556 Connecting Profiler to Profiled Scope
http://go/wvgerrit/16557 Android Reading Profiler History
http://go/wvgerrit/16574 Adding Get Stats Method
http://go/wvgerrit/16606 Seperating Session Parsing
http://go/wvgerrit/16607 Adding get stats method to DRMPlugin
http://go/wvgerrit/16608 Fixing Linux Build Failure
http://go/wvgerrit/16612 Stop Clearing History
http://go/wvgerrit/16613 Accessing profiler information using session id
http://go/wvgerrit/16614 Making All Session Subsets of Global Session

BUG: 25123303
BUG: 26027857
Change-Id: Ie2422e644aa631871852ea0e461695aeb7060f88
2016-01-27 10:14:46 -08:00

72 lines
1.5 KiB
C++

// Copyright 2016 Google Inc. All Rights Reserved.
#ifndef WVCDM_PROFILER_ENTRY_WRITER_H_
#define WVCDM_PROFILER_ENTRY_WRITER_H_
#include <stddef.h>
#include <stdint.h>
namespace wvcdm {
namespace oemprofiler {
class EntryWriter {
public:
explicit EntryWriter();
const uint8_t* GetData() const;
size_t GetSize() const;
int WriteU8(uint8_t value);
int WriteU16(uint16_t value);
int WriteU32(uint32_t value);
int WriteU64(uint64_t value);
// WriteVLV
// Write a uint 64 value using a variable number of bytes. The number
// of bytes used is based on the number of bytes required to
// express the value.
//
// The first 3 bits are used to express the number of bytes
// (ranging 1 to 8 bytes).
//
// 1 byte = 0 to 31
// 2 bytes = 32 to 8191
// 3 bytes = 8192 to 2097151
// 4 bytes = 2097152 to 536870911
// 5 bytes = 536870912 to 137438953471
// 6 bytes = 137438953472 to 35184372088831
// 7 bytes = 35184372088832 to 9007199254740991
// 8 bytes = 9007199254740992 to 2305843009213693951
int WriteVLV(uint64_t value);
void Clear();
size_t GetFreeSpace() const;
private:
static const size_t kBufferSize = 32;
uint8_t bytes_[kBufferSize];
size_t write_head_;
int Write(uint64_t v, size_t num_bytes);
template <typename T>
int Write(T v);
uint8_t GetByte(uint64_t value, size_t byte_index);
// disallow copy and assign
EntryWriter(const EntryWriter&);
void operator=(const EntryWriter&);
};
} // oemprofiler
} // wvcdm
#endif