Resource Allocation for Heterogeneous Applications With Device-to-Device Communication Underlaying Cellular Networks