Loading include/media/stagefright/foundation/AAtomizer.h 0 → 100644 +51 −0 Original line number Diff line number Diff line /* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef A_ATOMIZER_H_ #define A_ATOMIZER_H_ #include <stdint.h> #include <media/stagefright/foundation/ABase.h> #include <media/stagefright/foundation/AString.h> #include <utils/List.h> #include <utils/Vector.h> #include <utils/threads.h> namespace android { struct AAtomizer { static const char *Atomize(const char *name); private: static AAtomizer gAtomizer; Mutex mLock; Vector<List<AString> > mAtoms; AAtomizer(); const char *atomize(const char *name); static uint32_t Hash(const char *s); DISALLOW_EVIL_CONSTRUCTORS(AAtomizer); }; } // namespace android #endif // A_ATOMIZER_H_ include/media/stagefright/foundation/ABase.h 0 → 100644 +25 −0 Original line number Diff line number Diff line /* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef A_BASE_H_ #define A_BASE_H_ #define DISALLOW_EVIL_CONSTRUCTORS(name) \ name(const name &); \ name &operator=(const name &) #endif // A_BASE_H_ include/media/stagefright/foundation/ABuffer.h 0 → 100644 +71 −0 Original line number Diff line number Diff line /* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef A_BUFFER_H_ #define A_BUFFER_H_ #include <sys/types.h> #include <stdint.h> #include <media/stagefright/foundation/ABase.h> #include <utils/RefBase.h> namespace android { struct AMessage; struct ABuffer : public RefBase { ABuffer(size_t capacity); ABuffer(void *data, size_t capacity); void setFarewellMessage(const sp<AMessage> msg); uint8_t *base() { return (uint8_t *)mData; } uint8_t *data() { return (uint8_t *)mData + mRangeOffset; } size_t capacity() const { return mCapacity; } size_t size() const { return mRangeLength; } size_t offset() const { return mRangeOffset; } void setRange(size_t offset, size_t size); void setInt32Data(int32_t data) { mInt32Data = data; } int32_t int32Data() const { return mInt32Data; } sp<AMessage> meta(); protected: virtual ~ABuffer(); private: sp<AMessage> mFarewell; sp<AMessage> mMeta; void *mData; size_t mCapacity; size_t mRangeOffset; size_t mRangeLength; int32_t mInt32Data; bool mOwnsData; DISALLOW_EVIL_CONSTRUCTORS(ABuffer); }; } // namespace android #endif // A_BUFFER_H_ include/media/stagefright/foundation/ADebug.h 0 → 100644 +105 −0 Original line number Diff line number Diff line /* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef A_DEBUG_H_ #define A_DEBUG_H_ #include <string.h> #include <media/stagefright/foundation/ABase.h> #include <media/stagefright/foundation/AString.h> namespace android { enum LogType { VERBOSE, INFO, WARNING, ERROR, FATAL, }; struct Logger { Logger(LogType type); virtual ~Logger(); template<class T> Logger &operator<<(const T &x) { mMessage.append(x); return *this; } private: android::AString mMessage; LogType mLogType; DISALLOW_EVIL_CONSTRUCTORS(Logger); }; const char *LeafName(const char *s); #undef LOG #define LOG(type) Logger(type) << LeafName(__FILE__) << ":" << __LINE__ << " " #define CHECK(condition) \ do { \ if (!(condition)) { \ LOG(FATAL) << "CHECK(" #condition ") failed."; \ } \ } while (false) #define MAKE_COMPARATOR(suffix,op) \ template<class A, class B> \ AString Compare_##suffix(const A &a, const B &b) { \ AString res; \ if (!(a op b)) { \ res.append(a); \ res.append(" vs. "); \ res.append(b); \ } \ return res; \ } MAKE_COMPARATOR(EQ,==) MAKE_COMPARATOR(NE,!=) MAKE_COMPARATOR(LE,<=) MAKE_COMPARATOR(GE,>=) MAKE_COMPARATOR(LT,<) MAKE_COMPARATOR(GT,>) #define CHECK_OP(x,y,suffix,op) \ do { \ AString ___res = Compare_##suffix(x, y); \ if (!___res.empty()) { \ LOG(FATAL) << "CHECK_" #suffix "(" #x "," #y ") failed: " \ << ___res; \ } \ } while (false) #define CHECK_EQ(x,y) CHECK_OP(x,y,EQ,==) #define CHECK_NE(x,y) CHECK_OP(x,y,NE,!=) #define CHECK_LE(x,y) CHECK_OP(x,y,LE,<=) #define CHECK_LT(x,y) CHECK_OP(x,y,LT,<) #define CHECK_GE(x,y) CHECK_OP(x,y,GE,>=) #define CHECK_GT(x,y) CHECK_OP(x,y,GT,>) #define TRESPASS() LOG(FATAL) << "Should not be here." } // namespace android #endif // A_DEBUG_H_ include/media/stagefright/foundation/AHandler.h 0 → 100644 +54 −0 Original line number Diff line number Diff line /* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef A_HANDLER_H_ #define A_HANDLER_H_ #include <media/stagefright/foundation/ALooper.h> #include <utils/RefBase.h> namespace android { struct AMessage; struct AHandler : public RefBase { AHandler() : mID(0) { } ALooper::handler_id id() const { return mID; } protected: virtual void onMessageReceived(const sp<AMessage> &msg) = 0; private: friend struct ALooperRoster; ALooper::handler_id mID; void setID(ALooper::handler_id id) { mID = id; } DISALLOW_EVIL_CONSTRUCTORS(AHandler); }; } // namespace android #endif // A_HANDLER_H_ Loading
include/media/stagefright/foundation/AAtomizer.h 0 → 100644 +51 −0 Original line number Diff line number Diff line /* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef A_ATOMIZER_H_ #define A_ATOMIZER_H_ #include <stdint.h> #include <media/stagefright/foundation/ABase.h> #include <media/stagefright/foundation/AString.h> #include <utils/List.h> #include <utils/Vector.h> #include <utils/threads.h> namespace android { struct AAtomizer { static const char *Atomize(const char *name); private: static AAtomizer gAtomizer; Mutex mLock; Vector<List<AString> > mAtoms; AAtomizer(); const char *atomize(const char *name); static uint32_t Hash(const char *s); DISALLOW_EVIL_CONSTRUCTORS(AAtomizer); }; } // namespace android #endif // A_ATOMIZER_H_
include/media/stagefright/foundation/ABase.h 0 → 100644 +25 −0 Original line number Diff line number Diff line /* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef A_BASE_H_ #define A_BASE_H_ #define DISALLOW_EVIL_CONSTRUCTORS(name) \ name(const name &); \ name &operator=(const name &) #endif // A_BASE_H_
include/media/stagefright/foundation/ABuffer.h 0 → 100644 +71 −0 Original line number Diff line number Diff line /* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef A_BUFFER_H_ #define A_BUFFER_H_ #include <sys/types.h> #include <stdint.h> #include <media/stagefright/foundation/ABase.h> #include <utils/RefBase.h> namespace android { struct AMessage; struct ABuffer : public RefBase { ABuffer(size_t capacity); ABuffer(void *data, size_t capacity); void setFarewellMessage(const sp<AMessage> msg); uint8_t *base() { return (uint8_t *)mData; } uint8_t *data() { return (uint8_t *)mData + mRangeOffset; } size_t capacity() const { return mCapacity; } size_t size() const { return mRangeLength; } size_t offset() const { return mRangeOffset; } void setRange(size_t offset, size_t size); void setInt32Data(int32_t data) { mInt32Data = data; } int32_t int32Data() const { return mInt32Data; } sp<AMessage> meta(); protected: virtual ~ABuffer(); private: sp<AMessage> mFarewell; sp<AMessage> mMeta; void *mData; size_t mCapacity; size_t mRangeOffset; size_t mRangeLength; int32_t mInt32Data; bool mOwnsData; DISALLOW_EVIL_CONSTRUCTORS(ABuffer); }; } // namespace android #endif // A_BUFFER_H_
include/media/stagefright/foundation/ADebug.h 0 → 100644 +105 −0 Original line number Diff line number Diff line /* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef A_DEBUG_H_ #define A_DEBUG_H_ #include <string.h> #include <media/stagefright/foundation/ABase.h> #include <media/stagefright/foundation/AString.h> namespace android { enum LogType { VERBOSE, INFO, WARNING, ERROR, FATAL, }; struct Logger { Logger(LogType type); virtual ~Logger(); template<class T> Logger &operator<<(const T &x) { mMessage.append(x); return *this; } private: android::AString mMessage; LogType mLogType; DISALLOW_EVIL_CONSTRUCTORS(Logger); }; const char *LeafName(const char *s); #undef LOG #define LOG(type) Logger(type) << LeafName(__FILE__) << ":" << __LINE__ << " " #define CHECK(condition) \ do { \ if (!(condition)) { \ LOG(FATAL) << "CHECK(" #condition ") failed."; \ } \ } while (false) #define MAKE_COMPARATOR(suffix,op) \ template<class A, class B> \ AString Compare_##suffix(const A &a, const B &b) { \ AString res; \ if (!(a op b)) { \ res.append(a); \ res.append(" vs. "); \ res.append(b); \ } \ return res; \ } MAKE_COMPARATOR(EQ,==) MAKE_COMPARATOR(NE,!=) MAKE_COMPARATOR(LE,<=) MAKE_COMPARATOR(GE,>=) MAKE_COMPARATOR(LT,<) MAKE_COMPARATOR(GT,>) #define CHECK_OP(x,y,suffix,op) \ do { \ AString ___res = Compare_##suffix(x, y); \ if (!___res.empty()) { \ LOG(FATAL) << "CHECK_" #suffix "(" #x "," #y ") failed: " \ << ___res; \ } \ } while (false) #define CHECK_EQ(x,y) CHECK_OP(x,y,EQ,==) #define CHECK_NE(x,y) CHECK_OP(x,y,NE,!=) #define CHECK_LE(x,y) CHECK_OP(x,y,LE,<=) #define CHECK_LT(x,y) CHECK_OP(x,y,LT,<) #define CHECK_GE(x,y) CHECK_OP(x,y,GE,>=) #define CHECK_GT(x,y) CHECK_OP(x,y,GT,>) #define TRESPASS() LOG(FATAL) << "Should not be here." } // namespace android #endif // A_DEBUG_H_
include/media/stagefright/foundation/AHandler.h 0 → 100644 +54 −0 Original line number Diff line number Diff line /* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef A_HANDLER_H_ #define A_HANDLER_H_ #include <media/stagefright/foundation/ALooper.h> #include <utils/RefBase.h> namespace android { struct AMessage; struct AHandler : public RefBase { AHandler() : mID(0) { } ALooper::handler_id id() const { return mID; } protected: virtual void onMessageReceived(const sp<AMessage> &msg) = 0; private: friend struct ALooperRoster; ALooper::handler_id mID; void setID(ALooper::handler_id id) { mID = id; } DISALLOW_EVIL_CONSTRUCTORS(AHandler); }; } // namespace android #endif // A_HANDLER_H_