Build fixes for MIPS platform

- Cross compile
- Add missing typesdefs for MIPS CPU
- Disable internal video render and pulse audio
- Add BRUNO define
- Hook up mediaengine audio and nexus library

Change-Id: Ia1f321dd5e8ebc891368931c520dc1b0938950f4
diff --git a/build/common.gypi b/build/common.gypi
index a37498f..122a520 100644
--- a/build/common.gypi
+++ b/build/common.gypi
@@ -581,6 +581,15 @@
     # from the system include dirs.
     'system_libcros%': 0,
 
+    # This indicated the build on bruno
+    'bruno%': 0,
+    'bruno_cross_compile%': '<(bruno_cross_compile)',
+    'bruno_pkg_config%': '<(bruno_pkg_config)',
+
+    # This indicated 32/64 bit mips target arch
+    'mips64%': 0,
+    # 'mips_abi%': '<(mips_abi)',
+
     # NOTE: When these end up in the Mac bundle, we need to replace '-' for '_'
     # so Cocoa is happy (http://crbug.com/20441).
     'locales': [
@@ -631,7 +640,7 @@
     'conditions': [
       # Used to disable Native Client at compile time, for platforms where it
       # isn't supported (ARM)
-      ['target_arch=="arm" and chromeos == 1', {
+      ['(target_arch=="arm" and chromeos == 1) or target_arch=="mips"', {
         'disable_nacl%': 1,
        }, {
         'disable_nacl%': 0,
@@ -2685,6 +2694,15 @@
         ['LINK.host', '$(LINK)'],
       ],
     }],
+    ['bruno==1', {
+      'defines': ['BRUNO'],
+      'make_global_settings': [
+        ['CC.target'  , '<(bruno_cross_compile)' + 'gcc'],
+        ['CXX.target' , '<(bruno_cross_compile)' + 'g++'],
+        ['LINK.target', '<(bruno_cross_compile)' + 'g++'],
+        ['AR.target'  , '<(bruno_cross_compile)' + 'ar'],
+      ],
+    }],
   ],
   'xcode_settings': {
     # DON'T ADD ANYTHING NEW TO THIS BLOCK UNLESS YOU REALLY REALLY NEED IT!
diff --git a/src/build/common.gypi b/src/build/common.gypi
index 297ab26..3ed63c7 100644
--- a/src/build/common.gypi
+++ b/src/build/common.gypi
@@ -94,6 +94,10 @@
             # http://code.google.com/p/webrtc/issues/detail?id=163
             'clang_use_chrome_plugins%': 0,
           }],
+        ['bruno==1', {
+          'include_internal_video_render%': 0,
+          'include_pulse_audio%': 0,
+          }],
         ],
       }],
     ], # conditions
diff --git a/src/modules/audio_device/main/source/audio_device.gypi b/src/modules/audio_device/main/source/audio_device.gypi
index 0683337..2c823b3 100644
--- a/src/modules/audio_device/main/source/audio_device.gypi
+++ b/src/modules/audio_device/main/source/audio_device.gypi
@@ -108,6 +108,8 @@
                 'libraries': [
                   '-ldl',
                   '-lasound',
+                  '<!@(<(bruno_pkg_config) --libs nexus)',
+                  '-lvcme_audio',
                 ],
               },
               'conditions': [
diff --git a/src/modules/audio_device/main/source/linux/audio_mixer_manager_alsa_linux.h b/src/modules/audio_device/main/source/linux/audio_mixer_manager_alsa_linux.h
index 94ea982..1634f94 100644
--- a/src/modules/audio_device/main/source/linux/audio_mixer_manager_alsa_linux.h
+++ b/src/modules/audio_device/main/source/linux/audio_mixer_manager_alsa_linux.h
@@ -16,6 +16,10 @@
 #include "critical_section_wrapper.h"
 #include "alsasymboltable_linux.h"
 
+#ifdef BRUNO
+#include "audiomixer.h"
+#endif
+
 #include <alsa/asoundlib.h>
 
 namespace webrtc
@@ -59,7 +63,9 @@
 
 private:
     WebRtc_Word32 LoadMicMixerElement() const;
+#ifndef BRUNO
     WebRtc_Word32 LoadSpeakerMixerElement() const;
+#endif  // BRUNO
     void GetControlName(char *controlName, char* deviceName) const;
 
 private:
diff --git a/src/system_wrappers/source/cpu_info.cc b/src/system_wrappers/source/cpu_info.cc
index e367abf..85d029f 100644
--- a/src/system_wrappers/source/cpu_info.cc
+++ b/src/system_wrappers/source/cpu_info.cc
@@ -21,6 +21,7 @@
 // Not implemented yet, might be possible to use Linux implementation
 #else // defined(WEBRTC_LINUX)
 #include <sys/sysinfo.h>
+#include <unistd.h>
 #endif
 
 #include "trace.h"
diff --git a/src/typedefs.h b/src/typedefs.h
index ba87309..c52aae1 100644
--- a/src/typedefs.h
+++ b/src/typedefs.h
@@ -56,7 +56,19 @@
 //   http://www.agner.org/optimize/calling_conventions.pdf
 //   or with gcc, run: "echo | gcc -E -dM -"
 // TODO(andrew): replace WEBRTC_LITTLE_ENDIAN with WEBRTC_ARCH_LITTLE_ENDIAN?
-#if defined(_M_X64) || defined(__x86_64__)
+#if defined(__mips__)
+#if defined(__MIPSEL__)
+#define WEBRTC_ARCH_LITTLE_ENDIAN
+#elif defined(__MIPSEB__)
+#else
+#error Unknown MIPS endian
+#endif  // __MIPSEL__
+#if defined(__mips64)
+#define WEBRTC_ARCH_64_BITS
+#else  // mips 32 bits
+#define WEBRTC_ARCH_32_BITS
+#endif  // __mips64
+#elif defined(_M_X64) || defined(__x86_64__)
 #define WEBRTC_ARCH_X86_FAMILY
 #define WEBRTC_ARCH_X86_64
 #define WEBRTC_ARCH_64_BITS
diff --git a/third_party/libsrtp/libsrtp.gyp b/third_party/libsrtp/libsrtp.gyp
index c0baae8..80c1713 100644
--- a/third_party/libsrtp/libsrtp.gyp
+++ b/third_party/libsrtp/libsrtp.gyp
@@ -35,6 +35,23 @@
           'SIZEOF_UNSIGNED_LONG_LONG=8',
         ],
       }],
+      ['target_arch=="mips" or 'target_arch=="mipsel"', {
+        'conditions': [
+          'mips_abi==64', {
+            'defines': [
+              'CPU_RISC',
+              'SIZEOF_UNSIGNED_LONG=8',
+              'SIZEOF_UNSIGNED_LONG_LONG=8',
+            ],
+          }, {
+            'defines': [
+              'CPU_RISC',
+              'SIZEOF_UNSIGNED_LONG=4',
+              'SIZEOF_UNSIGNED_LONG_LONG=8',
+            ],
+          },
+        ],
+      }],
       ['OS!="win"', {
         'defines': [
           'HAVE_STDINT_H',
@@ -76,6 +93,23 @@
             'SIZEOF_UNSIGNED_LONG_LONG=8',
           ],
         }],
+        ['target_arch=="mips" or target_arch=="mipsel"', {
+          'conditions': [
+            'mips_abi==64', {
+              'defines': [
+                'CPU_RISC',
+                'SIZEOF_UNSIGNED_LONG=8',
+                'SIZEOF_UNSIGNED_LONG_LONG=8',
+              ],
+            }, {
+              'defines': [
+                'CPU_RISC',
+                'SIZEOF_UNSIGNED_LONG=4',
+                'SIZEOF_UNSIGNED_LONG_LONG=8',
+              ],
+            },
+          ],
+        }],
         ['OS!="win"', {
           'defines': [
             'HAVE_STDINT_H',