Let AudioCodingModule::SendCodec return Maybe<CodecInst>

And deal with the consequences thereof...

Review URL: https://codereview.webrtc.org/1406123011

Cr-Commit-Position: refs/heads/master@{#10497}
diff --git a/webrtc/modules/audio_coding/main/test/APITest.cc b/webrtc/modules/audio_coding/main/test/APITest.cc
index 1313f35..81880be 100644
--- a/webrtc/modules/audio_coding/main/test/APITest.cc
+++ b/webrtc/modules/audio_coding/main/test/APITest.cc
@@ -823,9 +823,11 @@
       exit(-1);
   }
 
-  CodecInst myCodec;
-  if (sendACM->SendCodec(&myCodec) < 0) {
-    AudioCodingModule::Codec(_codecCntrA, &myCodec);
+  auto myCodec = sendACM->SendCodec();
+  if (!myCodec) {
+    CodecInst ci;
+    AudioCodingModule::Codec(_codecCntrA, &ci);
+    myCodec = rtc::Maybe<CodecInst>(ci);
   }
 
   if (!_randomTest) {
@@ -837,12 +839,12 @@
     *thereIsDecoder = false;
   }
   //myEvent->Wait(20);
-  CHECK_ERROR_MT(receiveACM->UnregisterReceiveCodec(myCodec.pltype));
+  CHECK_ERROR_MT(receiveACM->UnregisterReceiveCodec(myCodec->pltype));
   Wait(1000);
 
-  int currentPayload = myCodec.pltype;
+  int currentPayload = myCodec->pltype;
 
-  if (!FixedPayloadTypeCodec(myCodec.plname)) {
+  if (!FixedPayloadTypeCodec(myCodec->plname)) {
     int32_t i;
     for (i = 0; i < 32; i++) {
       if (!_payloadUsed[i]) {
@@ -850,9 +852,9 @@
           fprintf(stdout,
                   "Register receive codec with new Payload, AUDIO BACK.\n");
         }
-        //myCodec.pltype = i + 96;
-        //CHECK_ERROR_MT(receiveACM->RegisterReceiveCodec(myCodec));
-        //CHECK_ERROR_MT(sendACM->RegisterSendCodec(myCodec));
+        //myCodec->pltype = i + 96;
+        //CHECK_ERROR_MT(receiveACM->RegisterReceiveCodec(*myCodec));
+        //CHECK_ERROR_MT(sendACM->RegisterSendCodec(*myCodec));
         //myEvent->Wait(20);
         //{
         //    WriteLockScoped wl(_apiTestRWLock);
@@ -868,17 +870,17 @@
         //    *thereIsDecoder = false;
         //}
         //myEvent->Wait(20);
-        //CHECK_ERROR_MT(receiveACM->UnregisterReceiveCodec(myCodec.pltype));
+        //CHECK_ERROR_MT(receiveACM->UnregisterReceiveCodec(myCodec->pltype));
         Wait(1000);
 
-        myCodec.pltype = currentPayload;
+        myCodec->pltype = currentPayload;
         if (!_randomTest) {
           fprintf(stdout,
                   "Register receive codec with default Payload, AUDIO BACK.\n");
           fflush (stdout);
         }
-        CHECK_ERROR_MT(receiveACM->RegisterReceiveCodec(myCodec));
-        //CHECK_ERROR_MT(sendACM->RegisterSendCodec(myCodec));
+        CHECK_ERROR_MT(receiveACM->RegisterReceiveCodec(*myCodec));
+        //CHECK_ERROR_MT(sendACM->RegisterSendCodec(*myCodec));
         myEvent->Wait(20);
         {
           WriteLockScoped wl(_apiTestRWLock);
@@ -890,7 +892,7 @@
       }
     }
     if (i == 32) {
-      CHECK_ERROR_MT(receiveACM->RegisterReceiveCodec(myCodec));
+      CHECK_ERROR_MT(receiveACM->RegisterReceiveCodec(*myCodec));
       {
         WriteLockScoped wl(_apiTestRWLock);
         *thereIsDecoder = true;
@@ -902,9 +904,9 @@
               "Register receive codec with fixed Payload, AUDIO BACK.\n");
       fflush (stdout);
     }
-    CHECK_ERROR_MT(receiveACM->RegisterReceiveCodec(myCodec));
-    //CHECK_ERROR_MT(receiveACM->UnregisterReceiveCodec(myCodec.pltype));
-    //CHECK_ERROR_MT(receiveACM->RegisterReceiveCodec(myCodec));
+    CHECK_ERROR_MT(receiveACM->RegisterReceiveCodec(*myCodec));
+    //CHECK_ERROR_MT(receiveACM->UnregisterReceiveCodec(myCodec->pltype));
+    //CHECK_ERROR_MT(receiveACM->RegisterReceiveCodec(*myCodec));
     myEvent->Wait(20);
     {
       WriteLockScoped wl(_apiTestRWLock);
@@ -1001,22 +1003,17 @@
 }
 
 void APITest::CurrentCodec(char side) {
-  CodecInst myCodec;
-  if (side == 'A') {
-    _acmA->SendCodec(&myCodec);
-  } else {
-    _acmB->SendCodec(&myCodec);
-  }
+  auto myCodec = (side == 'A' ? _acmA : _acmB)->SendCodec();
 
   if (!_randomTest) {
     fprintf(stdout, "\n\n");
     fprintf(stdout, "Send codec in Side A\n");
     fprintf(stdout, "----------------------------\n");
-    fprintf(stdout, "Name................. %s\n", myCodec.plname);
-    fprintf(stdout, "Sampling Frequency... %d\n", myCodec.plfreq);
-    fprintf(stdout, "Rate................. %d\n", myCodec.rate);
-    fprintf(stdout, "Payload-type......... %d\n", myCodec.pltype);
-    fprintf(stdout, "Packet-size.......... %d\n", myCodec.pacsize);
+    fprintf(stdout, "Name................. %s\n", myCodec->plname);
+    fprintf(stdout, "Sampling Frequency... %d\n", myCodec->plfreq);
+    fprintf(stdout, "Rate................. %d\n", myCodec->rate);
+    fprintf(stdout, "Payload-type......... %d\n", myCodec->pltype);
+    fprintf(stdout, "Packet-size.......... %d\n", myCodec->pacsize);
   }
 
   Wait(100);