Home | History | Annotate | Download | only in libmedia
      1 /*
      2  * Copyright (C) 2013 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 //#define LOG_NDEBUG 0
     18 #define LOG_TAG "IMediaHTTPService"
     19 #include <utils/Log.h>
     20 
     21 #include <media/IMediaHTTPService.h>
     22 
     23 #include <binder/Parcel.h>
     24 #include <media/IMediaHTTPConnection.h>
     25 
     26 namespace android {
     27 
     28 enum {
     29     MAKE_HTTP = IBinder::FIRST_CALL_TRANSACTION,
     30 };
     31 
     32 struct BpMediaHTTPService : public BpInterface<IMediaHTTPService> {
     33     BpMediaHTTPService(const sp<IBinder> &impl)
     34         : BpInterface<IMediaHTTPService>(impl) {
     35     }
     36 
     37     virtual sp<IMediaHTTPConnection> makeHTTPConnection() {
     38         Parcel data, reply;
     39         data.writeInterfaceToken(
     40                 IMediaHTTPService::getInterfaceDescriptor());
     41 
     42         remote()->transact(MAKE_HTTP, data, &reply);
     43 
     44         status_t err = reply.readInt32();
     45 
     46         if (err != OK) {
     47             ALOGE("Unable to make HTTP connection (err = %d)", err);
     48             return NULL;
     49         }
     50 
     51         return interface_cast<IMediaHTTPConnection>(reply.readStrongBinder());
     52     }
     53 };
     54 
     55 IMPLEMENT_META_INTERFACE(
     56         MediaHTTPService, "android.media.IMediaHTTPService");
     57 
     58 } // namespace android
     59