Implement MediaProvider#getOriginalMediaFormatFileDescriptor
Test: TranscodeTest
Bug: 170488060
Change-Id: I74e9e0de58a2b6283ddc1a485f5aecfcfd9eb609
diff --git a/jni/node-inl.h b/jni/node-inl.h
index 8a97496..9b30e87 100644
--- a/jni/node-inl.h
+++ b/jni/node-inl.h
@@ -19,6 +19,7 @@
#include <android-base/logging.h>
+#include <sys/types.h>
#include <atomic>
#include <cstdint>
#include <limits>
@@ -127,24 +128,24 @@
// Creates a new node with the specified parent, name and lock.
static node* Create(node* parent, const std::string& name, const std::string& io_path,
bool should_invalidate, bool transforms_complete, const int transforms,
- const int transforms_reason, std::recursive_mutex* lock,
+ const int transforms_reason, std::recursive_mutex* lock, ino_t ino,
NodeTracker* tracker) {
// Place the entire constructor under a critical section to make sure
// node creation, tracking (if enabled) and the addition to a parent are
// atomic.
std::lock_guard<std::recursive_mutex> guard(*lock);
return new node(parent, name, io_path, should_invalidate, transforms_complete, transforms,
- transforms_reason, lock, tracker);
+ transforms_reason, lock, ino, tracker);
}
// Creates a new root node. Root nodes have no parents by definition
// and their "name" must signify an absolute path.
- static node* CreateRoot(const std::string& path, std::recursive_mutex* lock,
+ static node* CreateRoot(const std::string& path, std::recursive_mutex* lock, ino_t ino,
NodeTracker* tracker) {
std::lock_guard<std::recursive_mutex> guard(*lock);
node* root = new node(nullptr, path, path, false /* should_invalidate */,
true /* transforms_complete */, 0 /* transforms */,
- 0 /* transforms_reason */, lock, tracker);
+ 0 /* transforms_reason */, lock, ino, tracker);
// The root always has one extra reference to avoid it being
// accidentally collected.
@@ -358,10 +359,13 @@
// through the hierarchy exists.
static const node* LookupAbsolutePath(const node* root, const std::string& absolute_path);
+ // Looks up for the node with the given ino rooted at |root|, or nullptr if no such node exists.
+ static const node* LookupInode(const node* root, ino_t ino);
+
private:
node(node* parent, const std::string& name, const std::string& io_path,
const bool should_invalidate, const bool transforms_complete, const int transforms,
- const int transforms_reason, std::recursive_mutex* lock, NodeTracker* tracker)
+ const int transforms_reason, std::recursive_mutex* lock, ino_t ino, NodeTracker* tracker)
: name_(name),
io_path_(io_path),
transforms_complete_(transforms_complete),
@@ -373,6 +377,7 @@
should_invalidate_(should_invalidate),
deleted_(false),
lock_(lock),
+ ino_(ino),
tracker_(tracker) {
tracker_->NodeCreated(this);
Acquire();
@@ -526,6 +531,8 @@
bool should_invalidate_;
bool deleted_;
std::recursive_mutex* lock_;
+ // Inode number of the file represented by this node.
+ const ino_t ino_;
NodeTracker* const tracker_;